【发布时间】:2020-07-27 21:18:40
【问题描述】:
我正在尝试将以下 3 个查询修改为一个具有最终输出的查询。
第一个查询返回 ids 和 Places 列表
Select id,place from Global where status='Y';
查询示例输出:-
1)123,德里
2)345,查谟
3)456,哈里亚纳邦
然后我想把这个输出发送给
Licence 和 DrvingLicence 表进行过滤,如果这两个表中的 id 将 id 从最终输出中排除。
licenceId=id 和drivingLicenceNo=id
Select licenceId from Licence table where state='MO' and licenceid=:id
Select drivingLicenceNo from DrvingLicence table where DOB='12/12/1978' and drivingLicenceNo=:id
Place 仅出现在 "Global" 表中,该表应出现在最终输出中。
最终输出:
1)123,德里
假设许可证表中存在 id=345 并且 DrvingLicence 表中存在 id=456
【问题讨论】:
-
您使用的是 MySQL 还是 Oracle?
-
一些示例表数据和预期结果会有所帮助 - 都是格式化文本,而不是图像。 (minimal reproducible example.)
标签: mysql sql oracle oracle11g oracle-sqldeveloper