select * from school where class1 like '%钢材%'or class2 like '%钢材%'or class3 like '%钢材%'or class4 like '%钢材%' ;
那rs.getString("这里写哪个?") class1 或 class2 ? 怎么去确定?
明白你说的了,那只能这样 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 '%钢材%' 一个语句实现比较困难
--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
class1 或 class2 ?
怎么去确定?
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 '%钢材%'
一个语句实现比较困难
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