mysql使用in子句会抛出错误

时间:2014-10-23 09:43:18

标签: mysql

SELECT * FROM `mybb_main1threads` 
ORDER BY `mybb_main1threads`.`tid` 
DESC LIMIT 0,5 
WHERE `mybb_main1threads`.`fid` IN ( 155, 157, 160, 159, 158, 141 );
  

#1064 - 您的SQL语法出错;查看与您的MySQL服务器版本相对应的手册,以获得正确的语法,以便在其附近使用' WHERE fid IN(155,157,160,159,158,141)'在第4行

1 个答案:

答案 0 :(得分:4)

SELECT * 
FROM mybb_main1threads 
WHERE mybb_main1threads.fid IN ( 155, 157, 160, 159, 158, 141 )
ORDER BY mybb_main1threads.tid DESC 
LIMIT 0,5 

关键字需要按特定顺序排列。这个顺序是

select
from 
join
where
group by
having
order by
limit