在表dba_users中,我在USERNAME列中有以下值:
Expecting <valid port number 10-65535> here: '1q0'
Parse failed
Remaining unparsed: '11-1q0'
我想写一个只返回WZHBIJ
LALA
LOLO
MMISROK1
MMISROK2
MMISROK3
MMISROK4
MMISROK5
MMISROK6
WZHMEJ
和WZHBIJ
的SELECT语句,但我必须使用“NOT IN”。
所以,我想坚持使用NOT IN的概念:
WZHMEJ
答案 0 :(得分:2)
您可以使用NOT IN
两次:
select u.*
from dba_users u
where u.username not in (select u2.username
from dba_users u2
where u2.username not in ('WZHBIJ', 'WZHMEJ')
);
我不明白这种练习的目的。
答案 1 :(得分:1)
如果您只能使用NOT IN
,可以尝试:
SELECT username
FROM dba_users
WHERE username NOT IN (
'LALA'
,'LOLO'
)
AND username NOT IN (
SELECT username
FROM dba_users
WHERE username LIKE 'MMISROK%'
)
答案 2 :(得分:1)
这次使用CTE给予另一种“味道”;
WITH sub_query
AS (SELECT username
FROM dba_users
WHERE username LIKE 'MMIS%'
OR username LIKE 'L%L%')
SELECT *
FROM dba_users du
WHERE mu.username NOT IN (SELECT username FROM sub_query)