如何在MySQL中搜索以A开头的名称?
为此,请使用LIKE,如下所示-
select *from yourTableName where yourColumnName LIKE 'A%';
让我们首先创建一个表-
mysql> create table DemoTable ( StudentName varchar(100) );
现在您可以使用insert命令在表中插入一些记录-
mysql> insert into DemoTable values('John Smith');
mysql> insert into DemoTable values('Adam Smith');
mysql> insert into DemoTable values('Aaron Taylor');
mysql> insert into DemoTable values('Chris Brown');使用select语句显示表中的所有记录-
mysql> select *from DemoTable;
输出结果
+--------------+ | StudentName | +--------------+ | John Smith | | Adam Smith | | Aaron Taylor | | Chris Brown | +--------------+ 4 rows in set (0.00 sec)
以下是在MySQL中搜索以A开头的名称的查询-
mysql> select *from DemoTable where StudentName LIKE 'A%';
输出结果
+--------------+ | StudentName | +--------------+ | Adam Smith | | Aaron Taylor | +--------------+ 2 rows in set (0.00 sec)
热门推荐
10 发给导师的祝福语简短
11 小清新的祝福语简短
12 宝宝新年祝福语大全简短
13 春节送祝福语简短的
14 祝贺新婚祝福语古代简短
15 给新年祝福语简短独特
16 高考祝福语 简短12字
17 简短古文生日祝福语
18 日常祝福语简短语客户