MySQL vertical table to horizontal table need join cannot direct where connection

Source: Internet
Author: User

Select t.student_id, T4.name, T5.name, Ifnull (T6.name, "")
From Student_info t
Left join Student_type t1 in t.student_id=t1.student_id and T1.level=0 left joins student_type_info T4 on T1.type_id=t4.id
Left join Student_type T2 in t.student_id=t2.student_id and T2.level=1 left joins Student_type_info T5 on T2.type_id=t5.id
Left join Student_type T3 in t.student_id=t3.student_id and t3.level=2 left joins Student_type_info T6 on T3.type_id=t6.id
Order BY t.student_id;

MySQL vertical table to horizontal table need join cannot direct where connection

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.