我有4个名为A、B、C、D
的表。我有2个条件来获取数据
条件1
Select *
From A, B, C
Where //All 3 tables are joined with conditions
limit 1; // Display 1 data at a time
条件2
Select *
From A, B, D
Where //All 3 tables are joined with conditions
limit 1; // Display 1 data at a time
我正在寻找的是将以上2个Select语句
组合起来,以便
如果条件1
中存在数据,则显示数据
或显示条件2
中的数据
我怎样才能获得以上的功能?
你可以这样做
if exists(/*First query*/)
begin
/*FirstQuery*/
end
else
begin
/*Second Query*/
end