表1
hostname
111表2
hostname
222
111
333
444表3
hostname
555
666
777
888表1是条件,要在表2或者表3中查询出hostname名相同的,谁能告诉我啊,谢谢拉

解决方案 »

  1.   

    查出表2和表三中和表1相同的select * from table1,table2 where table1.hostname=table2.hostname union all
    select * from table1,table3 where table1.hostname=table3.hostname
      

  2.   

    算了,简化一下
    表2和表3分别在不同的数据库,然后查询相同的一个条件,比如xin,应该如何写呢
      

  3.   

    hehe ,写错了吧,简单是简单,不过,要留心。
      

  4.   

    错在 select * ,应该指明是那个表的。select db2.table2.* from db1.table1,db2.table2 where db1.table1.hostname=db2.table2.hostname union all
    select db2.table2.* from db1.table1,db2.table3 where db1.table1.hostname=db2.table3.hostname