我在这里很困惑第一个sql -
我的cnt_content
表中有一个条目content_pk=5419441
和title=test wls-2
现在我正在运行这个sql 1 -
SELECT
title,
content_pk
FROM
cnt_content c
WHERE
c.type not in (
'AMT', 'LPA', 'QUE'
)
AND c.private_flag = 'N'
AND c.searchable_flag = 'Y'
AND c.status in (
'PUB', 'NAP'
)
AND (
trim(c.title) LIKE 'test wls-2'
OR trim(c.special_keyword) LIKE 'test wls-2'
)
and not exists (
SELECT
1
FROM
cmd_content_metadata cmd
WHERE
cmd.content_pk=5419441
AND cmd.for_others='Y'
)
ORDER BY
c.last_modified_date desc;
正在给出结果 - content_pk=5419441
和title=test wls-2
但是当我运行这个sql 2 -
时SELECT
title,
content_pk
FROM
cnt_content c
WHERE
c.type not in (
'AMT', 'LPA', 'QUE'
)
AND c.private_flag = 'N'
AND c.searchable_flag = 'Y'
AND c.status in (
'PUB', 'NAP'
)
AND (
trim(c.title) LIKE 'test wls-2'
OR trim(c.special_keyword) LIKE 'test wls-2'
)
and not exists (
SELECT
1
FROM
cmd_content_metadata cmd
WHERE
cmd.content_pk=c.content_pk
AND cmd.for_others='Y'
)
ORDER BY
c.last_modified_date desc;
没有给出任何结果。任何人请解释。
答案 0 :(得分:0)
因为在一个中你只是将content_pk的特定值赋予5419441
,而另一个使用核心查询,这意味着对于在外部查询中选择的content_pk的每个值,您在子选择查询中检查是否相等