could you check and tell me where i have made a mistake? Here is the code:
$sql = "SELECT prekės.* , CONCAT(vartotojai.name) as v_name
FROM prekės
LEFT JOIN vartotojai
ON vartotojai.V_ID=prekės.V_ID
ORDER BY prekės.date
LIMIT $offset, $rec_limit
WHERE prekės.category='Telefonai'";
The error comes from the last line with WHERE
clause.
Clause order is incorrect : WHERE
-> ORDER
-> LIMIT
:
$sql = "SELECT prekės.*
, CONCAT(vartotojai.name) as v_name
FROM prekės LEFT JOIN vartotojai ON vartotojai.V_ID=prekės.V_ID
WHERE prekės.category='Telefonai'
ORDER BY prekės.date
LIMIT $offset, $rec_limit
";
Check the order . ORDER
and LIMIT
should go after WHERE
.
In order to ensure you are crafting well designed SQL, it is a good idea to check the link I provided. Once you get it, it's actually quite easy to understand the why of it.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.