MYSQL Correlation Query

Source: Internet
Author: User
Tags joins

1. Internal connection

Connect the same meaning field in two tables and return the information that is present in the two tables:

SELECT * from Tablea,tableb where TableA. field c=tableb. field C;

SELECT * FROM TableA inner join TableB on TableA. field c=tableb. field C;

TableA. field C=tableb. field C is a filter condition.

2. Left Outer connection

Use each record in the first table to match the record for the second table, regardless of whether it matches the record, the query results show all the contents of the first table

SELECT * from TableA left outer joins TableB on TableA. field c=tableb. field C;

3. Right outer connection

Use each record in the second table to match the record for the first table, regardless of whether it matches the record, the query results show all the contents of the second table

SELECT * FROM TableA right outer join TableB on TableA. field c=tableb. field C;

4. Full connection

Left OUTER join and right outer JOIN and set

SELECT * from TableA left outer joins TableB on TableA. field C=tableb. field C Union select * FROM TableA right outer join TableB on TableA. field C=tableb. field C

5. Correlated sub-query

The result of the first query is used as a condition for the second query.

MYSQL Correlation Query

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.