1,select 查找数据
创建stu列表,插入数据结果如下:
mysql> select * from stu; #读取列表stu中所有数据 +------+-----------------------+------------+ | name | addr | birthday | +------+-----------------------+------------+ | 丁 | 海南省海口市 | 1995-08-12 | | 丙 | 江苏省南京市 | 1997-12-22 | | 乙 | 北京市东城区 | 1997-09-22 | | 己 | 河北省石家庄市 | 1996-09-02 | | 戊 | 四川省成都市 | 1996-09-02 | | 甲 | 浙江省杭州市 | 1998-02-22 | +------+-----------------------+------------+ 6 rows in set (0.00 sec)
1.1,查找列表中的所有字段
select * from table_name;#例如上面
1.2 查找列表某一特定字段的所有值
select field1,field2,.. from table_name;
mysql> select name from stu; +------+ | name | +------+ | 丁 | | 丙 | | 乙 | | 己 | | 戊 | | 甲 | +------+ 6 rows in set (0.00 sec)
1.3,查找列表某一条件下的特定字段的值 where条件语句
select field1,field2... from table_name where field;
mysql> select name,birthday from stu where addr ='海南省海口市'; +------+------------+ | name | birthday | +------+------------+ | 丁 | 1995-08-12 | +------+------------+ 1 row in set (0.00 sec)
1.4, 模糊选择 like字句
select field1... from table_name where filed like '%';
mysql> select name,birthday from stu where addr like '北京%'; +------+------------+ | name | birthday | +------+------------+ | 乙 | 1997-09-22 | +------+------------+ 1 row in set (0.00 sec)