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.