mysql 如何同时查询3个表

有3个一模一样的表 table1 table2 table3, 下面这样的查询语句,如何同 查这3个表的 符号条件a='12' 的id?
SELECT id FROM table1 where a='12'
SELECT id FROM table2 where a='12'

SELECT id FROM table3 where a='12'

如果a是唯一的话那就select table1.id,table2.id,table3.id from table1,table2,table3 where table1.a='12' and table1.a=table2.a and table2.a=table3.a;
或者如果对下你给数据相同的话,可以用union 连接 在用一个标志位,区分三张表!
温馨提示:答案为网友推荐,仅供参考

相关了解……

你可能感兴趣的内容

本站内容来自于网友发表,不代表本站立场,仅表示其个人看法,不对其真实性、正确性、有效性作任何的担保
相关事宜请发邮件给我们
© 非常风气网