让我们首先创建一个表-
create table DemoTable ( Id int NOT NULL AUTO_INCREMENT PRIMARY KEY, Name varchar(100) );
使用插入命令在表中插入一些记录-
insert into DemoTable(Name) values('John Smith'); insert into DemoTable(Name) values('Carol Taylor'); insert into DemoTable(Name) values('John Doe'); insert into DemoTable(Name) values('Chris Brown'); insert into DemoTable(Name) values('John Brown');
使用select语句显示表中的所有记录-
select *from DemoTable;
这将产生以下输出-
+----+--------------+ | Id | Name | +----+--------------+ | 1 | John Smith | | 2 | Carol Taylor | | 3 | John Doe | | 4 | Chris Brown | | 5 | John Brown | +----+--------------+ 5 rows in set (0.00 sec)
以下是如果单元格中的字符串匹配则删除表行的查询-
delete from DemoTable where Name like '%ohn%';
让我们再次检查表记录-
select *from DemoTable;
这将产生以下输出-
+----+--------------+ | Id | Name | +----+--------------+ | 2 | Carol Taylor | | 4 | Chris Brown | +----+--------------+ 2 rows in set (0.00 sec)