Mysql (7) In-depth select query

Source: Internet
Author: User


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;

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.