提问者:小点点

我如何一起使用2个Select语句?[副本]


我有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中的数据

我怎样才能获得以上的功能?


共1个答案

匿名用户

你可以这样做

if exists(/*First query*/)
begin

/*FirstQuery*/

end

else

begin

/*Second Query*/

end