【发布时间】:2021-04-14 15:08:29
【问题描述】:
我有 4 个名为 A, B, C, D 的表。我有2 conditons to get the data
Condition 1
Select *
From A, B, C
Where //All 3 tables are joined with conditions
limit 1; // Display 1 data at a time
Condition 2
Select *
From A, B, D
Where //All 3 tables are joined with conditions
limit 1; // Display 1 data at a time
我是什么looking for is to combine above 2 Select Statement 这样
If Data Exists in Condition 1 然后Display Data 或 Display Data from condition 2
如何实现上述功能?
【问题讨论】:
-
mysql和postgresql是不同的数据库,你为什么要同时标记两个? (选择一个。) -
在第二个查询中执行 WHERE NOT EXISTS(
)....并将查询 1 合并到新查询 2 -
@Cato 好的,让我试试。我不能简单地使用
OR吗?