它不会返回任何内容..我收到错误
SELECT *
FROM projects
WHERE 1
AND category_id =10
AND position ASC ORDER BY limit 0,16
..错误说
#1064 - You have an error in your SQL syntax; check the manual that corresponds to your
MySQL server version for the right syntax to use near 'ASC ORDER BY limit 0,16' at line 1
答案 0 :(得分:2)
根据您的查询判断,我认为您正在尝试将“一切”放在表“项目”上,使用“类别10”,按“位置”排序,并将结果限制为前16行。
如果猜测是正确的,也许你的意思是:
SELECT *
FROM projects
WHERE category_id = 10
ORDER BY position ASC
LIMIT 16
答案 1 :(得分:0)
您的查询出了问题:
SELECT * FROM projects WHERE 1 AND category_id =10 AND position
WHERE 1
和AND position
没有任何意义。
答案 2 :(得分:0)
关键字asc
仅用于 order by
子句中的。不是在它之前。此外,order by
需要一个或多个列或表达式。也许你的意思是:
SELECT *
FROM projects
WHERE 1
AND category_id =10
ORDER BY position asc
limit 0,16
答案 3 :(得分:0)
我认为问题来自Where子句
SELECT * 来自项目 在哪里1 - >在这里你应该将列与á值进行比较 AND category_id = 10 AND位置ASC ORDER BY限制0,16 //缺少位置值
它应该是像
这样的东西SELECT *
FROM projects
WHERE place = 'London' //place is column name
AND category_id =10
AND position = 1 ASC ORDER BY limit 0,16 //position value is 1