One SQL statement queries two fields in both tables

Source: Internet
Author: User

First, the problem is described, and the Student table has field startid,endid. The ID in the Garde table needs to correspond to the Startid in the student table or Endid in the student table to find the Name field in the Grade table, and then the problem is, what if I need a SQL sentence to find out the two data in the Garde table? (The association field of two tables is SID)

Sql= "Select B.name,c.name as Name2

From student A,garde B,grade C

where A.sid=b.sid

and A.sid=c.sid and A.startid=b.id

and A.endid=b.id "

One SQL statement queries two fields in both tables

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.