Statement collection for SQL multiple table queries

Source: Internet
Author: User

Today we're going to talk about the SQL statements about how to query multiple tables, first and foremost, the most common and sudden, and the most abrupt. Multi-Table Query method

SELECT * FROM A join B in A.uid=b.uid join C on C.uid=a.uid where uid=1

二、四个 Table Query

SELECT * Form a,b,c,d where A.uid=b.uid and B.uid=c.uid and C.uid=d.uid where uid=1

Third, the use of alias query

SELECT * FROM table1 as a,table2 as B where a.id=b.id and a.id=2

Four, left JOIN table query

SELECT * FROM table1 a LEFT join Table2 b where a.id=b.id and a.id=2


The above four query statements, the most speed to calculate left join, and finally if not in the must not have to use a multiple table joint query Oh.

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.