-
select Table 1Student number, Table 1Name, Table 1Gender, Table 2Subject 1 Comments, Table 3Subject 2 Comments.
from Table 1
left join Table 2 on Table 1Student ID = Table 2Student ID.
left join Table 3 on Table 1Student ID = Table 3Student ID.
-
select Table 1Student number, Table 1Name, Table 1
Gender, Subject 1 Comments, Subject 2 Comments from Table 1 Left Join Table 2 on Table 1Student ID = Table 2Student ID left join Table 3 on Table 1
Student ID = Table 3Student ID.
-
Using the federated query function, select aStudent ID, AName, AGender, bStudent ID, BSubject 1 Comments, cSubject 2 comments from Table 1 a, Table 2 b, Table 3 c where
-
select
a.Student ID, AName, ASex, max (b..)Subject 1), max (b.).Comment), max (c.Subject 2), max (c.).Comment)
from Table 1 a
Left join Table 2 b
on a.Student ID, BStudent ID.
Left Join Table 2 c
on a.Student ID = CStudent ID.
group by a.Student ID, AName, AGender.
-
There are about 100 tables in the database today, and 1) one of them is table1 for the product type. For example, id | typeint | varchar(500)
2) Each type of product will have different relevant information, table3 This information corresponds to the rest of the multiple tables, but each table has a similar structure, up to 4 fields, for example.
id | data1 | data2 | table2_fk
3) Another table is used to store the names of all types of specific products, table2
id | name | table1_fk
int | varchar(500) |
Referencing this should merge tables like table2 and table3 into a single table.
Just use two tables to save the product type table1 1 to multiple products.
id data1 data2 data3 data4 type table1_fk
data1 and data2 belong to one table.
data3 and data4 belong to one table.
Obviously, this is not very ideal, because there are many tables, and if you define it in this way, you will probably have a lot of fields in the new table.
Quoting this problem will definitely exist, if you want to reduce the number of tables, it must inevitably have some more redundant fields, no system has a perfect design of database tables, some things can not be the best, for example, if you want to query performance, you have to reduce the table query, to reduce the table naturally depends on the needs to meet and then merge some tables, naturally there are redundant fields, just find a way to find a balance between performance and redundant fields, that is, the best combination, this is to keep trying.
First, use the left join to completely find out the 1 table, then use the right join to completely find out the 2 tables, and finally merge the results. >>>More
Each table in a database can have only one primary key, and it is not possible to have multiple primary keys. >>>More
1. MySQL database has several configuration options that can help us capture inefficient SQL statements in a timely manner1, Slow Query Log >>>More
First, create a temporary table, and then remove the data from the author table and put it into the temporary table. >>>More
For example, compare the size of the four digits a, b, c, and d, and take xmin = the smallest number. For example: 1,2,3,4, then xmin=1;If 1, 2, 0, 3, then xmin=1, when all are 0, xmin=0 >>>More