什么意思?A等于a1加a2吗??

解决方案 »

  1.   

    select * from table1
    where A=B or A=a1 or A=a2
      

  2.   

    select * from table1
    where A=B and( A=a1 or A=a2)
    不是很明白你的意思
      

  3.   

    可能我的意思不太清楚,具体情况是这样子!
    同一个表中,有A和B,C三个字段,A字段存放名称,B字段存放名称的值。
    例如
     name     value  id
     主题词    1     1
     分类      2     1
     单位      3     2
     分数      4     2
     主题词    1     2
     分类      2     2我要查找的是 主题词=1 而且 分类=2 ,且id相同
      

  4.   

    select * from (select * from tablename where value=1) a,(select * from tablename where value=2) b where a.id=b.id
      

  5.   

    to zhaoyongzhu 
     恐怕不可以吧,我是想得到主题词等于1,分类等于2的???
      

  6.   

    数据时这些:
    name     value  id
     主题词    1     1
     分类      2     1
     单位      3     2
     分数      4     2
     主题词    1     2
     分类      2     2就说你最后想得到什么的数据吧。
      

  7.   

    是这个效果吗?
    SQL> select * from testaa;NAME                      VALUE         ID
    -------------------- ---------- ----------
    分类                          2          1
    单位                          3          2
    分数                          4          2
    主题词                        1          2
    主题词                        1          1
    分类                          2          26 rows selected.SQL> select a.name,a.value,b.name,b.value,a.id from (select * from testaa where
    value=1) a,(select * from testaa where value=2) b where a.id=b.id;NAME          VALUE NAME           VALUE         ID
    -------- ---------- --------- ---------- ----------
    主题词             1 分类               2          1
    主题词             1 分类               2          2
      

  8.   

    select * 
    from table1 a,table1 b
    where a.name = '主题词' and a.value = '1'
      and b.name = '分类' and a.value = '2'
      and a.id = b.id
    如果你喜欢自己加GROUP 或 DISTINCT去掉重复数据
      

  9.   

    select a.id,a.name,a.value from 
    (select id,name,value from tablename where name='主题词' and value=1) a,
    (select id,name,value from tablename where name='分类' and value=2) b
    where a.id=b.id
      

  10.   

    如果没有完全相同的记录的话
    select id from table
    where value=1 or value =2
    group by id
    having count(id)>1