当前位置: 代码迷 >> Sql Server >> 求条语句,该如何解决
  详细解决方案

求条语句,该如何解决

热度:75   发布时间:2016-04-27 19:40:52.0
求条语句
表:a
字段:id,cname


declare   @id   int
while(类似select   @id   =   id   from   a   where   cname   = 'xxx ')
begin
select   *   from   a   where   id   =@   id
end


----

while里的语句要求判断是否有满足条件的id存在,不存在就不进入while循环,[email protected],并进入循环.

while结构不可改变(do...while)不在考虑之列.




------解决方案--------------------
while exists (select * from a where cname= 'xxx ')
  相关解决方案