当前位置: 代码迷 >> Sql Server >> 关于变量定义简要
  详细解决方案

关于变量定义简要

热度:46   发布时间:2016-04-24 18:30:51.0
关于变量定义精简
请问一下各位大大.. 以下四个栏位都使用同一条件的话.. 可以精简成一行吗?

select @ItemName= (select itemname from shop where itemname = @Title)
select @ItemPrice= (select point from shop where itemname = @Title)
select @ItemInex= (select itemindex from shop where itemname = @Title)
select @AccectMsg= (select accectmsg from shop where itemname = @Title)
------解决方案--------------------
可以的:

select @ItemName = itemname ,
       @ItemPrice= point,
       @ItemInex = itemindex,
       @AccectMsg= accectmsg
from shop 
where itemname = @Title
  相关解决方案