gpt4 book ai didi

mysql - 获取左连接子查询为空(未找到)的行

转载 作者:行者123 更新时间:2023-11-29 06:51:54 24 4
gpt4 key购买 nike

如何获取连接子查询为空的行?

SELECT *
FROM bank_recon b
LEFT JOIN (
SELECT o.bank_recon_id
FROM data_voucher_ocr_bank o
LEFT JOIN data_voucher v ON v.id=o.data_voucher_id
WHERE v.is_ocr_verified=1
LIMIT 1
) s ON s.bank_recon_id=b.id
WHERE s IS NULL

更新

使用此查询(子查询)时,根据 is_ocr_verified 是否设置来获取某些内容

SELECT o.bank_recon_id
FROM data_voucher_ocr_bank o
LEFT JOIN data_voucher v ON v.id=o.data_voucher_id
WHERE v.is_ocr_verified=1 && o.bank_recon_id=320062

使用此查询时,无论如何都会获取所有内容!?

SELECT b.txt, b.amount
FROM bank_recon b
LEFT JOIN (
SELECT o.bank_recon_id
FROM data_voucher_ocr_bank o
LEFT JOIN data_voucher v ON v.id=o.data_voucher_id
WHERE v.is_ocr_verified=1
LIMIT 1
) s ON s.bank_recon_id=b.id
WHERE b.id=320062 && s.bank_recon_id IS NULL

最佳答案

WHERE 子句中指定列,而不仅仅是子查询。

WHERE s.bank_recon_id IS NULL

关于mysql - 获取左连接子查询为空(未找到)的行,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47105205/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com