Mysql (7) go deep into the select query link: Mysql (1) mysql Installation http://www.bkjia.com/database/201210/162314.html Mysql (2) Database Operations http://www.bkjia.com/database/201210/162315.html Mysql (3) operations on Data Tables http://www.bkjia.com/database/201210/162316.html Mysql (4) Data Table query operations http://www.bkjia.com/database/201210/162317.html Mysql (5) operation time http://www.bkjia.com/database/201210/162318.html;Mysql Those things (6) String Pattern Matching http://www.bkjia.com/database/201210/163969.html 1. The table alias www.2cto.com SELECT * FROM pet p order by p. age is used to sort the queried data BY the table's age. If you want to pair pets in a pet table, you can use the table alias: SELECT p1.name, p1.sex, p2, name, p2.sex FROM pet AS p1, pet AS p2 WHERE p1.species = p2.species AND p1.sex = "M" AND p2.sex = "F"; this statement means pairing by species, with m and f as gender; 2. query the pet name and type by column alias (directly reference the column name ). SELECT name, species FROM pet order by name, species; similar: SELECT name, species FROM pet order by 1, 2; this is the same as the above functions. Www.2cto.com can also be named as a column. SELECT name AS n, species AS s FROM pet order by n, s; this function is the same AS the preceding statement. Use the column alias in the clause: SELECT species, COUNT (*) AS total FROM pet group by species HAVING total> 1;