CREATE TABLE emp
(
empid int IDENTITY(1,1) PRIMARY KEY,
jobtitle varchar(50)
);
INSERT INTO emp
VALUES ('Programmer'), ('VP'), ('DBA');
我尝试使用以下,但它不工作
SELECT *
FROM emp
WHERE jobtitle LIKE '(PROG|VP)%';
SQL Server实际上并不支持任何正则表达式。您最好使用LIKE
:
SELECT *
FROM emp
WHERE UPPER(jobtitle) LIKE 'PROG%' OR UPPER(jobtitle) LIKE 'VP%';