SELECT
*
FROM
Table1
WHERE
EmpPU NOT LIKE '%CSE%'
AND EmpPU NOT LIKE '%ECE%'
AND EmpPU NOT LIKE '%EEE%'
如果需要对“任意数量”的值执行此操作,则可以将这些值放入表中并执行连接。
WITH
myData
AS
(
SELECT '%CSE%' AS match
UNION ALL SELECT '%ECE%' AS match
UNION ALL SELECT '%EEE%' AS match
)
SELECT
*
FROM
Table1
LEFT JOIN
myData
ON Table1.EmpPU LIKE myData.match
WHERE
myData.match IS NULL
或者..。
WITH
myData
AS
(
SELECT '%CSE%' AS match
UNION ALL SELECT '%ECE%' AS match
UNION ALL SELECT '%EEE%' AS match
)
SELECT
*
FROM
Table1
WHERE
NOT EXISTS (SELECT * FROM myData WHERE Table1.EmpPU LIKE match)
SELECT
*
FROM
Table1
WHERE NOT EXISTS
(
SELECT
NULL
FROM
(
SELECT '%CSE%' AS column1 UNION ALL
SELECT '%ECE%' UNION ALL
SELECT '%EEE%'
) AS tbl
WHERE Table1.EmpPU LIKE tbl.column1
)