当前位置: 代码迷 >> Sql Server >> 请教怎么精简上面几句SQL语句
  详细解决方案

请教怎么精简上面几句SQL语句

热度:39   发布时间:2016-04-24 23:19:29.0
请问如何精简下面几句SQL语句?
set @a=(select thea from tb1 where id=3)
set @b=(select theb from tb1 where id=3)
set @c=(select thec from tb1 where id=3)
set @d=(select thed from tb1 where id=3)


里面select的条件都一致,只是取的字段不同而已,难道给这四个变量赋值要查询4次?能否直接查询一次然后直接四个变量都赋值完呢?
求精简语句谢谢~

------解决方案--------------------
select @a=thea,@b=theb,@c=thec,@d=thed from tb1 where id=3
  相关解决方案