在MySQL中基于EmployeeId删除特定记录
让我们首先创建一个表-
create table DemoTable615 (EmployeeId varchar(100),EmployeeName varchar(100));
使用插入命令在表中插入一些记录-
insert into DemoTable615 values('EMP-101','Adam'); insert into DemoTable615 values('EMP-1001','David'); insert into DemoTable615 values('EMP-1002','Chris'); insert into DemoTable615 values('EMP-1003','Robert');
使用select语句显示表中的所有记录-
select *from DemoTable615;
这将产生以下输出-
+------------+--------------+ | EmployeeId | EmployeeName | +------------+--------------+ | EMP-101 | Adam | | EMP-1001 | David | | EMP-1002 | Chris | | EMP-1003 | Robert | +------------+--------------+ 4 rows in set (0.00 sec)
以下是删除特定记录的查询-
delete from DemoTable615 where EmployeeId='EMP-1002';
让我们再次检查表记录-
select *from DemoTable615;
这将产生以下输出-
+------------+--------------+ | EmployeeId | EmployeeName | +------------+--------------+ | EMP-101 | Adam | | EMP-1001 | David | | EMP-1003 | Robert | +------------+--------------+ 3 rows in set (0.00 sec)