SQL join on joint query instance

Source: Internet
Author: User

SQL join on joint query instance

SQL join-use join
In addition to the above method, we can also use the keyword join to obtain data from two tables.

If we want to list the orders of all users, we can use the following select statement:

Select persons. lastname, persons. firstname, orders. orderno
From persons
Inner join orders
On persons. id_p = orders. id_p

Instance 2

Select title, artist
From album join track
On (album. asin = track. album)
Where song = 'alison'


Reference two tables
We can obtain data from two tables by referencing two tables:

Who ordered the product and what product they ordered?

Select persons. lastname, persons. firstname, orders. orderno
From persons, orders
Where persons. id_p = orders. id_p


SQL join is used to query data from two or more tables based on the relationship between columns.

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.