我正在尝试从表中选择行,但开头的任何行都包含'NEW_'。我认为我的逻辑是正确的,但我不确定语法。谁能帮我吗?
SELECT *
FROM CUSTOMER e1
WHERE e1.cust_ref LIKE 'CUST_REF%'
AND e1.cust_ref NOT IN (SELECT e2.cust_ref
FROM CUSTOMER e2
WHERE e1.cust_ref = 'NEW_' + e2.cust_ref);
答案 0 :(得分:1)
select * from CUSTOMER
WHERE cust_ref like 'CUST_REF%'
AND cust_ref not in
(select cust_ref from sd_filter_element where cust_ref not like 'NEW_%');
您应该使用like
来执行此操作。
答案 1 :(得分:0)
以下是过滤器选项
的SQL查询select *
from sd_filter_element
WHERE
cust_ref not like 'NEW_%';
答案 2 :(得分:0)
如果您只是想要不具备" NEW _",为什么不这样做呢?
select c.*
from CUSTOMER c
WHERE c.cust_ref not like 'NEW_%' ;