SELECT ... FROM ... WHERE someFIELD IN(1,2,3,4)SELECT ... FROM ... WHERE someFIELD between 0 AND 5SELECT ... FROM ...
WHERE someFIELD = 1 OR someFIELD = 2 OR someFIELD = 3 ...
或者MySQL会以编译器优化代码的方式优化SQL吗?
编辑:更改AND到OR是因为评论中所述的原因。
慕标5832272
浏览 1623回答 3
3回答
慕田峪9158850
返回结果的总数为10000次中的7264次。SELECT * FROM item WHERE id = 1 OR id = 2 ... id = 10000这个查询0.1239秒数SELECT * FROM item WHERE id IN (1,2,3,...10000)这个查询0.0433秒数IN比OR