有一个表arrange 里面有一个字段是classType select *from arrange where classType='001'
select *from arrange where classType='002'
select *from arrange where classType='003'
select *from arrange where classType='004'上面语句只是条件classType中数值不同怎样让上面语句简便~?~好像用case
select *from arrange where classType='002'
select *from arrange where classType='003'
select *from arrange where classType='004'上面语句只是条件classType中数值不同怎样让上面语句简便~?~好像用case
select * from arrange where classType in('001','002','003','004')
UNION ALL
select *from arrange where classType='002'
UNION ALL
select *from arrange where classType='003'
UNION ALL
select *from arrange where classType='004'
在有索引的情况下,进行上面与水哥的比较看看
语句不知道会不会更好。。
UNION ALL
select *from arrange where classType='002'
UNION ALL
select *from arrange where classType='003'
UNION ALL
select *from arrange where classType='004'
select * from arrange where classType in ('001','002','003','004');
select *
from arrange
where (classType='001'
or classType='002'
or classType='003'
or classType='004')
或
select *from arrange where classType='001' or classType='002'
or classType='003' or classType='004'
或
select *from arrange where classType='001' or classType='002'
or classType='003' or classType='004'