Home >Backend Development >PHP Tutorial > 小弟我想查找同一字段内 某几个特定的值 如何优化

小弟我想查找同一字段内 某几个特定的值 如何优化

WBOY
WBOYOriginal
2016-06-13 13:23:01885browse

我想查找同一字段内 某几个特定的值 怎么优化。
SELECT * FROM `tab` WHERE a3=1 or a3=2 or a3=3 or a3=4 or a3=5..........a3=29 a3=30

查找a3内值为1到30的。怎么优化的更简洁。高效一点

------解决方案--------------------
a3 in(1,2,3)
------解决方案--------------------
SELECT * FROM `tab` WHERE a3 between 1 and 30 ;

这样试试。或者 in(1,2..................)
------解决方案--------------------
楼上2种都好,过于10个还是用between 好些吧..

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn