gpt4 book ai didi

sql - 右表的左连接与 where 子句(必须从右返回 NULL) - Oracle

转载 作者:行者123 更新时间:2023-12-02 08:33:38 25 4
gpt4 key购买 nike

我有 2 个表 ID 和 Comm。表格如下

 ID                          AppID   Name1       James2       John..100     JeffCommAppID  Comment1      abc1      def1      pqr2      abc2      def2      pqr3      def

I want all appID from ID (First table) and from Comm(Second table) I want only those comment which are equal to abc, rest others should be NULL.

I am using following query, not sure how do I filter comment abc and Null

select id.appid,comm.comment
from id left join comm on
id.appid=comm.appid
where comm.comment = 'abc'

我知道我的逻辑错了,我想弄清楚我应该在哪里改变。任何帮助表示赞赏。

最佳答案

select id.appid,comm.comment
from id
left join comm
on id.appid=comm.appid
and comm.comment = 'abc'

关于sql - 右表的左连接与 where 子句(必须从右返回 NULL) - Oracle,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24076454/

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