insert into ImgStore values(1,'asdfasd','') where
(select count(1) from ImgStore where pic_id = 'asdfasd') < 1为什么总报错,还有别的方法可以实现效果么?

解决方案 »

  1.   


    declare @t table(id int,myname nvarchar(10))insert into @t values(1,'asd')if((select count(1) from @t where id = 1) < 1)
    insert into @t values(1,'asd')select * from @t
      

  2.   


    if((select count(1) from ImgStore where pic_id = 'asdfasd') < 1)
    insert into ImgStore values(1,'asdfasd','')
      

  3.   


    if not exists (select 1 from ImgStore where pic_id = 'asdfasd')
    insert into ImgStore values(1,'asdfasd','')