select union 查询出来的结果,如何按指定顺序输出
如有以下sql语句:
select name from student where id='1003' union all select name from student where id='1001' union all select name from student where id='1004'
查询出来的结果顺序是未知的。
现在必须按照一定的顺序显示查询的结果,可以用这样的方法:
select name from ( select name ,2 flag from student where id='1003' union all select name ,1 flag from student where id='1001' union all select name ,3 flag from student where id='1004') tem order by flag
本文章转载请务必注明出处或保存此段。c++/lua/windows逆向交流群:69148232

浙公网安备 33010602011771号