表1,表2里都有"网卡号"这个字段,我现在想查一下一个网卡号s是不是在这两个表里面,用一条sql实现
select * from (表1 and 表2)where 网卡号=s
语法如何实现?

解决方案 »

  1.   

    SELECT * FROM 表1 WHERE 表1.网卡号 = (SELECT * FROM 表2 WHERE 表2.网卡号=s)
      

  2.   

    select * from 表1 where 网卡号=s
    and exists (select * from 表2 where 网卡号=s)
      

  3.   

    上面改为:
    SELECT * FROM 表1 WHERE 表1.网卡号 = (SELECT 表2.网卡号 FROM 表2 WHERE 表2.网卡号=s)
      

  4.   

    不好意思:
    是select * from (表1 or  表2)where 网卡号=s 或的关系?
      

  5.   

    select * from table1 where 网卡号=s
    union select * from table2 where 网卡号=s 
    假如两张表的字段不一样,那就取相同的字段就可以了,
    如有记录就说明有此网卡号存在
      

  6.   

    select 网卡号 from table1 union select 网卡号 from table2 
    为什么找出的条数比
    select 网卡号 from table1 还少?我现在想把两表的网卡号加起来显示出来,如何实现?
      

  7.   

    if @网卡号 in 
    (select distinct 网卡号 from 表1
    union 
    select distinct 网卡号 from 表2) then
    //在当中
      

  8.   

    select * from 表1 where 网卡号 in
    (select * from 表2 where 网卡号=s)
      

  9.   

    SELECT  * 
    FROM    T1 A
            ,T2 B
    WHERE
            A.fMac = B.fMac
      

  10.   

    SELECT  * 
    FROM    T1 A
            ,T2 B
    WHERE
            (A.fMac = B.fMac)
    AND     (A.fMac = :fMac)        
      

  11.   

    select * from (select a.* form 表1 a , 表2 b where a.网卡号=b.网卡号) c where 网卡号=:s