select colid
from syscolumns
where [name] = '钢材'
       [id] = object_id('表名')上面语句可以查询出'钢材'在表中是第几个字段

解决方案 »

  1.   

    select * from school where class1 like '%钢材%'or class2 like '%钢材%'or class3 like '%钢材%'or class4 like '%钢材%' ; 
      

  2.   

    那rs.getString("这里写哪个?")
                   class1 或 class2 ?
    怎么去确定?
      

  3.   

    明白你说的了,那只能这样
    select class1 from school where class1 like '%钢材%'
    select class2 from school where class2 like '%钢材%'
    select class3 from school where class3 like '%钢材%'
    select class4 from school where class4 like '%钢材%' 
    一个语句实现比较困难
      

  4.   

    --try
    select 
    case when charindex(class1,'钢材')>0 then class1 
         when charindex(class2,'钢材')>0 then class2
         when charindex(class3,'钢材')>0 then class3
         when charindex(class4,'钢材')>0 then class4
         else '' end as class
    from school
    where charindex(class1+class2+class3+class4,'钢材')>0