SQL语法实践(三):一些问题

Q:What’s the difference between INNER JOIN, LEFT JOIN, RIGHT JOIN and F
ULL JOIN? [duplicate]
A:点击跳转链接到原文
There are different types of joins available in SQL:

INNER JOIN: returns rows when there is a match in both tables.

LEFT JOIN: returns all rows from the left table, even if there are no matches in the right table.

RIGHT JOIN: returns all rows from the right table, even if there are no matches in the left table.

FULL JOIN: combines the results of both left and right outer joins.

The joined table will contain all records from both the tables and fill in NULLs for missing matches on either side.

SELF JOIN: joins a table to itself as if the table were two tables, temporarily renaming at least one table in the SQL statement.

CARTESIAN JOIN: returns the Cartesian product of the sets of records from the two or more joined tables.

We can take each first four joins in Details :

We have two tables with the following values.
SQL语法实践(三):一些问题_第1张图片
SQL语法实践(三):一些问题_第2张图片
SQL语法实践(三):一些问题_第3张图片
SQL语法实践(三):一些问题_第4张图片
SQL语法实践(三):一些问题_第5张图片
Q:Execution sequence of Group By, Having and Where clause in SQL Server?
A:chick

FROM & JOINs determine & filter rows
WHERE more filters on the rows
GROUP BY combines those rows into groups
HAVING filters groups
ORDER BY arranges the remaining rows/groups
LIMIT filters on the remaining rows/groups

你可能感兴趣的:(#,数据库技术及应用,sql,数据库)