How does one student query associated tables for multiple courses?

Source: Internet
Author: User
How does one student query associated tables for multiple courses? One student table
Student
Id name age six
1 Michael, 20 male
2 Zhang Si 19 male

Chinese table
Id keben feishu sid
1 yuwen 90 1
Mathematical table
Id keben feishu sid
1 shuyue 90 1
Physical table
Id keben feishu sid
1 wuli 90 1
There are many students who have the highest query efficiency. for example, they can query the Chinese, mathematics, and physics of Michael Jacob. The field names of these three tables are the same,


Reply to discussion (solution)

There is a problem with the table. if you just create one table, there will be a lot of usage.
Add the physical score field of Chinese mathematics in the user table and query it directly.

If you are afraid that there are too many fields in the user table, you can put the physical scores of Chinese mathematics into a table and perform normal join table queries.

Yes. this is just an example. In fact, the content of this table is more than that,

It's hard for everyone. please give me some advice.

Your problem is too abstract. I cannot figure out the scenario.
However, if the fields of Chinese mathematics and physics are the same, there is no need to create three tables. one table is enough. a type field is added to the table for differentiation.
Select * from user left join orders table on user. id = orders table. uid where user. name = 'Zhang SAN' and (type = 'Chinese' or type = 'mat' or type = 'Physical ')

The three tables are not exactly the same. Okay, thank you.

In fact, a student queries the relevant content in these three tables.

Okay, you have solved it yourself.

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.