让我们首先创建一个表-
mysql> create table DemoTable623 (FirstName varchar(100),LastName varchar(100),Age int);
使用插入命令在表中插入一些记录-
mysql> insert into DemoTable623 values('John','Smith',23); mysql> insert into DemoTable623 values('Adam','smith',23); mysql> insert into DemoTable623 values('Chris','Brown',24); mysql> insert into DemoTable623 values('Robert','brown',21);
使用select语句显示表中的所有记录-
mysql> select *from DemoTable623;
这将产生以下输出-
+-----------+----------+------+ | FirstName | LastName | Age | +-----------+----------+------+ | John | Smith | 23 | | Adam | smith | 23 | | Chris | Brown | 24 | | Robert | brown | 21 | +-----------+----------+------+ 4 rows in set (0.00 sec)
这是使用MySQL的select语句查询-
mysql> select FirstName from DemoTable623 where lower(LastName) ='smith';
这将产生以下输出-
+-----------+ | FirstName | +-----------+ | John | | Adam | +-----------+ 2 rows in set (0.00 sec)