2.1 阅读文档,找到SELECT的语法
http://dev.mysql.com/doc/refman/5.1/zh/sql-syntax.html#select
2.2 读SELECT的说明文档
2.3 实践文档提及的SELECT子句的功能,并提交自己的练习SQL和结果
mysql> select * from students;
+----+-------+----------+------------+
| id | name | addresss | year |
+----+-------+----------+------------+
| 1 | allen | Beijing | 1980-01-02 |
| 2 | pual | Shanghai | 1980-01-02 |
| 3 | john | dalian | 1980-01-02 |
+----+-------+----------+------------+
3 rows in set (0.00 sec)
mysql> select name,year from students;
+-------+------------+
| name | year |
+-------+------------+
| allen | 1980-01-02 |
| pual | 1980-01-02 |
| john | 1980-01-02 |
+-------+------------+
3 rows in set (0.00 sec)
mysql> select concat(name, ',', year) string from students order by string;
+------------------+
| string |
+------------------+
| allen,1980-01-02 |
| john,1980-01-02 |
| pual,1980-01-02 |
+------------------+
3 rows in set (0.00 sec
mysql> select t1.name, t2.name from students as t1, teachers as t2 where t1.name = t2.name;
+------+------+
| name | name |
+------+------+
| john | john |
+------+------+
1 row in set (0.00 sec)
mysql> select name, year, id from students order by name, year;
+-------+------------+----+
| name | year | id |
+-------+------------+----+
| allen | 1980-01-02 | 1 |
| john | 1980-01-02 | 3 |
| pual | 1980-01-02 | 2 |
+-------+------------+----+
3 rows in set (0.00 sec)
mysql> select name, year, id from students order by name DESC, year;
+-------+------------+----+
| name | year | id |
+-------+------------+----+
| pual | 1980-01-02 | 2 |
| john | 1980-01-02 | 3 |
| allen | 1980-01-02 | 1 |
+-------+------------+----+
3 rows in set (0.00 sec)
mysql> select name, count(year), id from students group by id;
+-------+-------------+----+
| name | count(year) | id |
+-------+-------------+----+
| allen | 1 | 1 |
| pual | 1 | 2 |
| john | 1 | 3 |
+-------+-------------+----+
3 rows in set (0.00 sec)