当前位置: 代码迷 >> ASP.NET >> 数据库已知其中一列的值如何查出该列的id
  详细解决方案

数据库已知其中一列的值如何查出该列的id

热度:4242   发布时间:2013-02-25 00:00:00.0
数据库已知其中一列的值怎么查出该列的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) 
  相关解决方案