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