select * from info where ljxh in ('BH5205','DF2376','HU3456')

解决方案 »

  1.   

    select * from info where lixh = 'bh5205' or lixh = ''..........
      

  2.   

    select * from info where charindex(ljxh+',','BH5205,DF2376,HU3456'+',') > 0
      

  3.   


    select * from info where ljxh in ('BH5205','DF2376','HU3456')
      

  4.   

    create procedure pro_1
     @ls_str varchar(200)  --'BH5205,DF2376,HU3456'
    as
    create #fanmb (ljxh varcha(20) null)
    declare @li_x integer,@ls_tmp varchar(2)select @li_x = PATINDEX ('%,%',@ls_str)
    while @li_x > 0
      begin
        select @ls_tmp = substring(@ls_str,1,li_x)
        insert #fanmb (ljxh) values (@ls_tmp)
        select @ls_str = substring(@ls_str,li_x + 1, len(@ls_str))
        select  @li_x = PATINDEX ('%,%',@ls_str)
      end
    if len(@ls_str) > 0 insert #fanmb (ljxh) values (@ls_str)
    select * from info where ljxh in (select ljxh from #fanmb)
    drop table #fanmb
      

  5.   

    select * from info where charindex(ljxh,'BH5205,DF2376,HU3456')<>0
      

  6.   

    select * from info where ljxh in ('BH5205','DF2376','HU3456')
    若为VB程序使用,可用VB语法灵活控制输入型号的个数,动态生成SQL语句再提交给SQL Server执行。