SQL查询语句两个表数据输出

来源:百度知道 编辑:UC知道 时间:2024/05/08 11:56:37
两个表结构一样!
A---------------------------
FID NAME
1 dasf

B---------------------------
FID NAME
1 erere

如何建立一个sql语句查询 结果要求
1 dasf
1 erere
这里的数值是不固定 不能用where

select fid,name from A where FID=1 and NAME='dasf' union
select fid,name from B where FID=2 and NAME='erere';

从两个表选出来的数据用union或union all 连接就可以,既然你能选出你想要的,两个连接一下就可以了

select a.*, select b.*,
from tablename a, table name b,