In SQL, the ( ) operator is used to merge query result sets, filling NULL values in unmatched rows. It allows performing outer joins, avoiding Cartesian products, and comes in two types: left outer join and right outer join. Left and right outer joins will return all rows from the left or right table, filling in NULL values for unmatched rows.
Usage of ( ) in SQL
In SQL query, ( ) operator is used to combine two The query result sets are merged and missing rows are filled with NULL values.
Syntax:
SELECT column_list FROM table1 LEFT|RIGHT (+) JOIN table2 ON join_condition;
Function:
Type:
Example:
Suppose we have the following two tables:
students | |
---|---|
id | name |
1 | John |
2 | Mary |
SELECT * FROM students LEFT (+) JOIN courses ON students.id = courses.id;
course_name | |
Math | |
Science | |
History |
Result:
##id
course_name | ||
---|---|---|
Math | ##2 | Mary |
NULL | NULL | |
The above is the detailed content of Usage of (+) in sql. For more information, please follow other related articles on the PHP Chinese website!