3表怎么联合查询

3表如何联合查询,在线等

表1

hostname

111

表2

hostname

222

111

333

444

表3

hostname

555

666

777

888

表1是条件,要在表2或者表3中查询出hostname名相同的,谁能告诉我啊,谢谢拉



查出表2和表三中和表1相同的

select * from table1,table2 where table1.hostname=table2.hostname union all

select * from table1,table3 where table1.hostname=table3.hostname



错在 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

3表怎么联合查询

相关文章:

你感兴趣的文章:

标签云: