gpt4 book ai didi

sql - 尝试删除 SQL 中以 Z 或 z 开头的姓氏

转载 作者:行者123 更新时间:2023-12-02 09:28:38 25 4
gpt4 key购买 nike

我的任务是删除任何姓名以 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','<a href="https://stackoverflow.com/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="2e445d5e4b42424740496e484f4d5b425a57005b435b4d004b4a5b" rel="noreferrer noopener nofollow">[email protected]</a>','1983-06-26','5');

insert into Faculty
values (10894, 'Ron','Danning','<a href="https://stackoverflow.com/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="295b4d48474740474e694f484a5c455d50075c445c4a074c4d5c" rel="noreferrer noopener nofollow">[email protected]</a>','1976-06-12','4');

insert into Faculty
values (23487, 'Blair','Davidson','<a href="https://stackoverflow.com/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="06646267706f6275696846606765736a727f28736b736528636273" rel="noreferrer noopener nofollow">[email protected]</a>','1977-08-27','2');

insert into Faculty
values (13456, 'David','Burtner','<a href="https://stackoverflow.com/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="f397918681879d9681b3959290869f878add869e8690dd969786" rel="noreferrer noopener nofollow">[email protected]</a>','1967-11-04','3');

insert into Faculty
values (78546, 'Jessica','Dawn','<a href="https://stackoverflow.com/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="e78d83869089a7818684928b939ec9928a9284c9828392" rel="noreferrer noopener nofollow">[email protected]</a>','1973-05-28','3');

insert into Faculty
values (23564, 'Randy','Zilman','<a href="https://stackoverflow.com/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="8efce9e7e2e3efe0cee8efedfbe2faf7a0fbe3fbeda0ebeafb" rel="noreferrer noopener nofollow">[email protected]</a>','1975-10-04','3');

insert into Faculty
values (85462, 'Carol','Lily','<a href="https://stackoverflow.com/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="93f0fffaffead3f5f2f0e6ffe7eabde6fee6f0bdf6f7e6" rel="noreferrer noopener nofollow">[email protected]</a>','1954-07-16','3');

insert into Faculty
values (45126, 'Jason','Borne','<a href="https://stackoverflow.com/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="91fbf3fee3fff4d1f7f0f2e4fde5e8bfe4fce4f2bff4f5e4" rel="noreferrer noopener nofollow">[email protected]</a>','1963-01-26','4');

insert into Faculty
values (65894, 'Tom','Cruise','<a href="https://stackoverflow.com/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="3c485f4e49554f597c5a5d5f49504845124951495f12595849" rel="noreferrer noopener nofollow">[email protected]</a>','1965-08-01','3');

insert into Faculty
values (56451, 'Michael','Jordan','<a href="https://stackoverflow.com/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="660b0c091402070826000705130a121f48130b130548030213" rel="noreferrer noopener nofollow">[email protected]</a>','1959-12-26','3');

DELETE FROM Faculty WHERE LastName='Z%'

我以为最后的语句会删除代码,但它并没有删除它,只是保持不变。任何帮助将不胜感激。

最佳答案

DELETE FROM Faculty WHERE LastName LIKE 'Z%'

使用通配符 % 时,您需要使用 LIKE 而不是 =。

关于sql - 尝试删除 SQL 中以 Z 或 z 开头的姓氏,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35464404/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com