Create a View
SQL code
CREATE VIEW view_name
as SELECT t1.xxx, t2.xxx, t3.xxx from table1 T1
-INNER
JOIN table2 on t2 = T1.fid )
INNER JOIN table3 t3 on t1.mid = T3.mid;
3 table associations are used here, and there is a trick to INNER JOIN notation for multiple table associations
1. First write the simplest 2-table Association INNER JOIN
2. Then use () to extend all the words from the post to the end of the statement
3. Start the connection with the INNER join of the next table at the end of the statement
Remember this principle, in the Future 4-table association, 5-Table association is not a difficult thing
Delete View
Copy Code code as follows:
This is supplemented by other netizens:
Multi-table joins are a very useful technique because in some cases we need to query data across multiple tables.
Syntax format:
From ((Table 1 INNER join table 2 on table 1. Field number = Table 2. Field number) INNER join table 3 on table 1. Field number = Table 3. Field number) INNER join table 4 on member. Field number = Table 4. Field no. = INNER Join Table x on member. Field number = table X. field number, just apply the format.
Precautions:
In the input letter process, must use the English Half-width punctuation mark, the word leaves the half corner space;
When you create a datasheet, if a table joins more than one table, the fields in this table must be of the number data type, and the same field in more than one table must be a primary key and an AutoNumber data type. Otherwise, it is difficult to connect successfully.
Code nesting Quick Method: For example, to connect five tables, just add a front and back bracket to the code that connects the four tables (the parentheses are appended to the from, the parentheses are appended to the end of the code), and then continue with the INNER JOIN table name x on table 1 after the parentheses. Field number = Table X. Field number Code, so you can join the data table indefinitely.
Use to connect two data tables:
from table 1 INNER JOIN table 2 on table 1. Field number = Table 2. Field number
Use to connect three data tables:
from (table 1 INNER join table 2 on table 1. Field number = Table 2. Field number) INNER JOIN table 3 on table 1. Field number = Table 3. Field number
Use to connect four data tables:
from (table 1 INNER JOIN table 2 on table 1. Field number = Table 2. Field number) INNER join table 3 on table 1. Field number = Table 3. Field number) INNER join table 4 on member. Field number = Table 4.
uses five data tables:
from ((Table 1 INNER join table 2 on table 1. Field number = Table 2. Field number) INNER join table 3 on table 1. Field number = Table 3. Field number) INNER Join Table 4 on member. Field number = Table 4. Field number INNER JOIN table 5 on member. Field number = Table 5. Field number