首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 数据库 > SQL Server >

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

2013-03-19 
请问如何精简下面几句SQL语句?set @a(select thea from tb1 where id3)set @b(select theb from tb1 wh

请问如何精简下面几句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

热点排行
Bad Request.