日期:2014-05-18  浏览次数:20551 次

查询两个表的问题
A总表
B,C子表

关联字段为D_NO

我现在要实现在,当B表里有数据时,显示B表的第一条记录,如果B表没数据时就显示C表的第一条记录

请问有什么好方法实现没有?

谢谢

------解决方案--------------------
SQL code
if exists(select * from B)
begin
select top 1 * from B
end
else
begin
select top 1 * from C
end