我的任务是删除名称以Z或z开头的任何教职员工。我已经尝试了一些我一直在研究的代码,但是无法使其正常工作。以下是创建表,插入表,最后我尝试删除条目的代码:
CREATE TABLE Faculty (
FacultyID int primary key,
FirstName varchar(30),
LastName varchar(30),
EMail varchar(60),
BirthDate DATE,
Numbr_Courses int
);
insert into Faculty
values (10579, 'John','Spelling','jspelling@faculty.umuc.edu','1983-06-26','5');
insert into Faculty
values (10894, 'Ron','Danning','rdanning@faculty.umuc.edu','1976-06-12','4');
insert into Faculty
values (23487, 'Blair','Davidson','bdavidson@faculty.umuc.edu','1977-08-27','2');
insert into Faculty
values (13456, 'David','Burtner','dburtner@faculty.umuc.edu','1967-11-04','3');
insert into Faculty
values (78546, 'Jessica','Dawn','jdawn@faculty.umuc.edu','1973-05-28','3');
insert into Faculty
values (23564, 'Randy','Zilman','rgilman@faculty.umuc.edu','1975-10-04','3');
insert into Faculty
values (85462, 'Carol','Lily','clily@faculty.umuc.edu','1954-07-16','3');
insert into Faculty
values (45126, 'Jason','Borne','jborne@faculty.umuc.edu','1963-01-26','4');
insert into Faculty
values (65894, 'Tom','Cruise','tcruise@faculty.umuc.edu','1965-08-01','3');
insert into Faculty
values (56451, 'Michael','Jordan','mjordan@faculty.umuc.edu','1959-12-26','3');
DELETE FROM Faculty WHERE LastName='Z%'
我认为最终的陈述会删除代码,但它并没有删除它只是保持不变。任何帮助将不胜感激。
答案 0 :(得分:5)
DELETE FROM Faculty WHERE LastName LIKE 'Z%'
使用通配符%时,您需要使用LIKE而不是=。