刚刚知道这样的语句:select s_no,s_name from user_s where s_grade in (1,2,3)
还不如下面的三句语句的速度快,在数据量上百万的时候,
select s_no,s_name from user_s where s_grade=1
select s_no,s_name from user_s where s_grade=2
select s_no,s_name from user_s where s_grade=3
想请教一下,第二种方法的的每条查询所得的结果能不能在输出时达到和第一条一样的效果,那么该怎么组合第二种方法结果记录集。谢谢
------解决方案--------------------
以下两种方法能达到你的要求.不需要存储过程
select s_no,s_name from user_s where s_grade=1 or s_grade=2 or s_grade=3
select s_no,s_name from user_s where s_grade=1
union all
select s_no,s_name from user_s where s_grade=2
union all
select s_no,s_name from user_s where s_grade=3