答案 0 :(得分:0)
这是一个合并的简单连接:
select a.ID, coalesce(a.email,b.email) as email
from tableA a
join tableB b on b.ID=a.ID
这假定两个表中都存在ID,而从您的示例来看,它们都存在。
答案 1 :(得分:0)
您可以像这样使用COALESCE函数:
select a.id,
coalesce(a.email, b.email) email
from table_a a, table_b b
where a.id = b.id;
以下是一个带有示例的SQL Fiddle的链接:http://sqlfiddle.com/#!17/14f12d/7