The inner connection is divided into three kinds: equivalent connection, natural connection and unequal connection.
The outer joins are divided into three types: Left outer join (either OUTER join or right join), and the outer join, or the all-inclusive (full OUTER join or complete join), and the out-of-the-OUTER join. Unlike an inner join, an outer join lists not only the rows that match the join criteria, but all the data rows in the left table (when the left outer join), the right table (when the right outer joins), or two tables (when you are connected on the outside), all of which match the search criteria.
A cross join has no WHERE clause, which returns the Cartesian product of all data rows in the join table, with the number of rows in the result set equal to the number of data rows in the first table that match the query criteria multiplied by the number of rows in the second table that meet the query criteria.
The ON (join_condition) clause in the JOIN operation indicates the join condition, which consists of columns and comparison operators, logical operators, and so on in the connected table.
Either connection cannot directly connect to the text, ntext, and image data type columns, but you can indirectly connect the three types of columns. For example:
SELECT P1.pub_id,p2.pub_id,p1.pr_info from pub_info as P1 INNER JOIN pub_info as P2 on datalength (p1.pr_info) =datalength (P2.pr_info)
(i) Internal connection
The INNER JOIN query operation lists the data rows that match the join criteria, and it uses comparison operators to compare the column values of the concatenated columns. There are three types of internal connections:
1. Equivalent connection: Use the equals sign (=) operator in the join condition to compare the column values of the joined columns, and the query results list all the columns in the joined table, including the repeating columns.
2, unequal connections: Use a comparison operator other than the equals operator in the join condition to compare the column values of the connected columns. These operators include >, >=, <=, <,!>,!& lt, and <>.
3. Natural connection: Use the Equals (=) operator in the join condition to compare the column values of the connected column, but it uses the selection list to indicate which columns are included in the query result collection and to delete the duplicate columns in the Join table.
example, the following uses the equivalent connection to list authors and publishers in the same city in the authors and Publishers tables:
SELECT * FROM authors as a INNER joins publishers as P on a.city=p.city
If you use a natural connection, delete the authors and Publishers tables in the select list (city and State):
SELECT A.*,p.pub_id,p.pub_name,p.country from authors as a INNER joins publishers as P on a.city=p.city
(ii) External connection
In the query results collection, only the rows that meet the query criteria (WHERE search condition or having condition) and join conditions are returned. In the case of an outer join, it returns to the query result collection not only the rows that meet the join criteria, but also all data rows in the left table (when left outer joins), the right table (when the right outer joins), or two edge tables (full outer joins).
Use the left OUTER join to connect the forum content and author information as follows:
SELECT a.*,b.* from Luntan left JOIN usertable as B on A.username=b.username
All the authors in the city table and all the authors in the user table, and the cities in which they are located, are used with the full outer join:
SELECT a.*,b.* OUTER JOIN user as B on a.username=b.username
(iii) Cross-linking
The cross join does not take a WHERE clause, it returns the Cartesian product of all data rows of the two connected tables, and the number of rows returned to the result set equals the number of data rows in the first table that meet the query criteria multiplied by the number of data rows in the second table that meet the query criteria.
example, there are 6 types of books in the titles table, and 8 publishers in the publishers table, the number of records retrieved by the following cross-connection will be equal to the 6*8=48 row.
SELECT Type,pub_name from the titles cross JOIN publishers ORDER by type
The table connection is introduced, more specifically the inner joins inside the connection. The INNER join selects only two records that match each other in the table. Therefore, this can lead to sometimes the records we need are not included. To better understand this concept, we introduce two tables for demonstration. A party and a Member's Table (MSP) in the Scottish Parliament.
What does an inner join and cross join in SQL mean?