有难度的SQL语句,类似高级语言的setch...case,在线求解.
表:stateData
sbid state1 state2 ... state22
00001 1 0 1
00001 0 0 0
表:alarm
sbid alarmName channel [while] [value]
00001 A类报警 S1 = 1
00001 A类报警 S22 = 1
说明:根据alarm中的条件来查询stateData里的数据,上面的例子可写为:
select*from stateData where state1 = 1 and state22 = 1
请问怎么根据channel的值来写SQL语句?