日期:2014-05-17  浏览次数:20459 次

数据库已知其中一列的值怎么查出该列的id
我数据库中的一个表是这样的
我知道subject1~~到subject6的一个值,我想查出我知道的这个值在那行,也就是id是多少。
比如说,我知道的是14,我想查出3来。该怎么做呢,各位大神帮帮忙。

------解决方案--------------------
select id from table where subject1 = 14 or subject2 = 14 or subject3 = 14 or subject4 = 14 or subject5 = 14 or subject6 = 14

------解决方案--------------------
select id from table where (subject1 = 14 or subject2 = 14 or subject3 = 14 or subject4 = 14 or subject5 = 14 or subject6 = 14)
------解决方案--------------------
select id from table where (subject1 = 14 or subject2 = 14 or subject3 = 14 or subject4 = 14 or subject5 = 14 or subject6 = 14)