Sei sulla pagina 1di 24

SQL Joins

SQL Joins are used to relate information in different tables. A Join condition is a part of the sql query that retrieves rows from two or more tables. A SQL Join condition is used in the SQL WHERE Clause of select, update, delete statements. The Syntax for joining two tables is:

SELECT FROM

col1, table_name1,

col2,

col3... table_name2

WHERE table_name1.col2 = table_name2.col1;

If a sql join condition is omitted or if it is invalid the join operation will result in a Cartesian product. The Cartesian product returns a number of rows equal to the product of all rows in all the tables being joined. For example, if the first table has 20 rows and the second table has 10 rows, the result will be 20 * 10, or 200 rows. This query takes a long time to execute. Lets use the below two tables to explain the sql join conditions. database table "product";

product_id

product_name supplier_name unit_price

100

Camera

Nikon

300

101

Television

Onida

100

102

Refrigerator

Vediocon

150

103

Ipod

Apple

75

104

Mobile

Nokia

50

database table "order_items";

order_id

product_id

total_units

customer

5100

104

30

Infosys

5101

102

Satyam

5102

103

25

Wipro

5103

101

10

TCS

SQL Joins can be classified into Equi join and Non Equi join. 1) SQL Equi joins It is a simple sql join condition which uses the equal sign as the comparison operator. Two types of equi joins are SQL Outer join and SQL Inner join. For example: You can get the information about a customer who purchased a product and the quantity of product. 2) SQL Non equi joins It is a sql join condition which makes use of some comparison operator other than the equal sign like >, <, >=, <=

1) SQL Equi Joins:


An a) b) SQL Outer Join equi-join is SQL further classified into Inner two categories: Join

a) SQL Inner Join:


All the rows returned by the sql query satisfy the sql join condition specified.

For example: If you want to display the product information for each order the query will be as given below. Since you are retrieving the data from two tables, you need to identify the common column between these two tables, which is theproduct_id. The query for this type of sql joins would be like,

SELECT FROM

order_id,

product_name,

unit_price,

supplier_name,

total_units order_items

product,

WHERE order_items.product_id = product.product_id;

The columns must be referenced by the table name in the join condition, because product_id is a column in both the tables and needs a way to be identified. This avoids ambiguity in using the columns in the SQL SELECT statement. The number of join conditions is (n-1), if there are more than two tables joined in a query where 'n' is the number of tables involved. The rule must be true to avoid Cartesian product. We can also use aliases to reference the column name, then the above query would be like,

SELECT

o.order_id,

p.product_name,

p.unit_price,

p.supplier_name,

o.total_units FROM product p, order_items o

WHERE o.product_id = p.product_id;

b) SQL Outer Join:


This sql join condition returns all rows from both tables which satisfy the join condition along with rows which do not satisfy the join condition from one of the tables. The sql outer join operator in Oracle is ( + ) and is used on one side of the join condition only. The syntax differs for different RDBMS implementation. Few of them represent the join conditions as "sql left outer join", "sql right outer join".

If you want to display all the product data along with order items data, with null values displayed for order items if a product has no order item, the sql query for outer join would be as shown below:

SELECT FROM

p.product_id,

p.product_name, o,

o.order_id, product

o.total_units p

order_items

WHERE o.product_id (+) = p.product_id;

The output would be like,

product_id product_name order_id total_units

-------------

-------------

------------- -------------

100

Camera

101

Television

5103

10

102

Refrigerator

5101

103

Ipod

5102

25

104

Mobile

5100

30

NOTE:If the (+) operator is used in the left side of the join condition it is equivalent to left outer join. If used on the right side of the join condition it is equivalent to right outer join.

SQL Self Join:


A Self Join is a type of sql join which is used to join a table to itself, particularly when the table has a FOREIGN KEY that references its own PRIMARY KEY. It is necessary to ensure that the join statement defines an alias for both copies of the table to avoid column ambiguity. The below query is an example of a self join,

SELECT a.sales_person_id, a.name, a.manager_id, b.sales_person_id, b.name FROM sales_person a, sales_person b

WHERE a.manager_id = b.sales_person_id;

2) SQL Non Equi Join:


A Non Equi Join is a SQL Join whose condition is established using all comparison operators except the equal (=) operator. Like >=, <=, <, > For example: If you want to find the names of students who are not studying either Economics, the sql query would be like, (lets use student_details table defined earlier.)

SELECT FROM

first_name,

last_name,

subject student_details

WHERE subject != 'Economics'

The output would be something like,

first_name last_name subject

--------------------- ----------------

Anajali

Bhagwat

Maths

Shekar

Gowda

Maths

Rahul

Sharma

Science

Stephen

Fleming

Science

Join (SQL)
From Wikipedia, the free encyclopedia Jump to: navigation, search

A SQL join clause combines records from two or more tables in a database.[1] It creates a set that can be saved as a table or used as is. A JOIN is a means for combining fields from two tables by using values common to each. ANSI standard SQL specifies four types of

JOIN s: INNER , OUTER , LEFT , and RIGHT . As a special case, a table


(base table, view, or joined table) can JOIN to itself in a self-join. A programmer writes a JOIN predicate to identify the records for joining. If the evaluated predicate is true, the combined record is then produced in the expected format, a record set or a temporary table.

Contents

1 Sample tables 2 Inner join o 2.1 Equi-join 2.1.1 Natural join 2.1.2 Cross join 3 Outer joins o 3.1 Left outer join o 3.2 Right outer join o 3.3 Full outer join 4 Self-join o 4.1 Example 5 Merge rows o 5.1 MySQL o 5.2 PostgreSQL o 5.3 Microsoft T-SQL 6 Alternatives 7 Implementation o 7.1 Join algorithms 8 See also 9 Notes 10 References 11 External links

[edit] Sample tables


Relational databases are often normalized to eliminate duplication of information when objects may have one-to-many relationships. For example, a Department may be associated with many different Employees. Joining two tables effectively creates another table which combines information from both tables. This is at some expense in terms of the time it takes to compute the join. While it is also possible to simply maintain such a table if speed is important, duplicate information may take extra space, and add the expense and complexity of maintaining data integrity if data which is duplicated later changes. All subsequent explanations on join types in this article make use of the following two tables. The rows in these tables serve to illustrate the effect of different types of joins and join-predicates. In the following tables the DepartmentID column of the

Department table (which can be designated as Department.DepartmentID ) is the primary key, while Employee.DepartmentID is a foreign key.

Employee Table LastName DepartmentID Rafferty Jones Steinberg Robinson Smith John 31 33 33 34 34
NULL

Department Table DepartmentID DepartmentName 31 33 34 35 Sales Engineering Clerical Marketing

Note: The "Marketing" Department currently has no listed employees. Also, employee "John" has not been assigned to any Department yet.

[edit] Inner join


An inner join is the most common join operation used in applications and can be regarded as the default join-type. Inner join creates a new result table by combining column values of two tables (A and B) based upon the join-predicate. The query compares each row of A with each row of B to find all pairs of rows which satisfy the join-predicate. When the joinpredicate is satisfied, column values for each matched pair of rows of A and B are combined into a result row. The result of the join can be defined as the outcome of first taking the Cartesian product (or Cross join) of all records in the tables (combining every record in table A with every record in table B)then return all records which satisfy the join predicate. Actual SQL implementations normally use other approaches like a hash join or a sort-merge join where possible, since computing the Cartesian product is very inefficient.

SQL specifies two different syntactical ways to express joins: "explicit join notation" and "implicit join notation". The "explicit join notation" uses the JOIN keyword to specify the table to join, and the

ON keyword to specify the predicates for the join, as in the following example:
SELECT * FROM employee INNER JOIN department ON employee.DepartmentID = department.DepartmentID;

The "implicit join notation" simply lists the tables for joining (in the FROM clause of the

SELECT statement), using commas to separate them. Thus, it specifies a cross join, and
the WHERE clause may apply additional filter-predicates (which function comparably to the join-predicates in the explicit notation). The following example shows a query which is equivalent to the one from the previous examples, but this time written using the implicit join notation:
SELECT * FROM employee, department WHERE employee.DepartmentID = department.DepartmentID;

The queries given in the examples above will join the Employee and Department tables using the DepartmentID column of both tables. Where the DepartmentID of these tables match (i.e. the join-predicate is satisfied), the query will combine the LastName, DepartmentID and DepartmentName columns from the two tables into a result row. Where the DepartmentID does not match, no result row is generated. Thus the result of the execution of either of the two queries above will be:
Employee.LastNam Employee.DepartmentI Department.DepartmentNam Department.DepartmentI e D e D Robinson Jones Smith Steinberg Rafferty 34 33 34 33 31 Clerical Engineering Clerical Engineering Sales 34 33 34 33 31

Note: Programmers should take special care when joining tables on columns that can contain NULL values, since NULL will never match any other value (not even NULL itself), unless the join condition explicitly uses the IS NULL or IS NOT NULL predicates. Notice that the employee "John" and the department "Marketing" do not appear in the query execution results. Neither of these has any matching records in the respective other table: "John" has no associated department, and no employee has the department ID 35. Thus, no information on John or on Marketing appears in the joined table. Depending on the desired results, this behavior may be a subtle bug. Outer joins may be used to avoid it. One can further classify inner joins as equi-joins, as natural joins, or as cross-joins.
[edit] Equi-join

An equi-join, also known as an equijoin, is a specific type of comparator-based join, or theta join, that uses only equality comparisons in the join-predicate. Using other comparison operators (such as < ) disqualifies a join as an equi-join. The query shown above has already provided an example of an equi-join:
SELECT * FROM employee JOIN department ON employee.DepartmentID = department.DepartmentID;

If columns in an equijoin have the same name, SQL/92 provides an optional shorthand notation for expressing equi-joins, by way of the USING construct[2]:
SELECT * FROM employee INNER JOIN department USING (DepartmentID);

The USING construct is more than mere syntactic sugar, however, since the result set differs from the result set of the version with the explicit predicate. Specifically, any columns mentioned in the USING list will appear only once, with an unqualified name, rather than once for each table in the join. In the above case, there will be a single

DepartmentID column and no employee.DepartmentID or department.DepartmentID .


The USING clause is not supported by SQL Server and Sybase.

[edit] Natural join

A natural join offers a further specialization of equi-joins. The join predicate arises implicitly by comparing all columns in both tables that have the same column-names in the joined tables. The resulting joined table contains only one column for each pair of equallynamed columns. Most experts agree that NATURAL JOINs are dangerous and therefore strongly discourage their use.[3] The danger comes from inadvertently adding a new column with a name that matches the other table. This means that any existing natural join will start comparing rows with different criteria than before, and will produce different results on the same data. The above sample query for inner joins can be expressed as a natural join in the following way:
SELECT * FROM employee NATURAL JOIN department;

As with the explicit USING clause, only one DepartmentID column occurs in the joined table, with no qualifier:
DepartmentID Employee.LastName Department.DepartmentName 34 33 34 33 31 Smith Jones Robinson Steinberg Rafferty Clerical Engineering Clerical Engineering Sales

PostgreSQL, MySQL and Oracle support natural joins, but not Microsoft T-SQL. The columns used in the join are implicit so the join code does not show which columns are expected, and a change in column names may change the results. An INNER JOIN performed on 2 tables having the same field name has the same effect. [4]
[edit] Cross join

CROSS JOIN returns the Cartesian product of rows from tables in the join. In other words, it will produce rows which combine each row from the first table with each row from the second table. [5] Example of an explicit cross join:
SELECT * FROM employee CROSS JOIN department;

Example of an implicit cross join:

SELECT * FROM employee, department;

Employee.LastNam Employee.DepartmentI Department.DepartmentNam Department.DepartmentI e D e D Rafferty Jones Steinberg Smith Robinson John Rafferty Jones Steinberg Smith Robinson John Rafferty Jones Steinberg Smith Robinson John Rafferty Jones 31 33 33 34 34
NULL

Sales Sales Sales Sales Sales Sales Engineering Engineering Engineering Engineering Engineering Engineering Clerical Clerical Clerical Clerical Clerical Clerical Marketing Marketing

31 31 31 31 31 31 33 33 33 33 33 33 34 34 34 34 34 34 35 35

31 33 33 34 34
NULL

31 33 33 34 34
NULL

31 33

Steinberg Smith Robinson John

33 34 34
NULL

Marketing Marketing Marketing Marketing

35 35 35 35

The cross join does not apply any predicate to filter records from the joined table. Programmers can further filter the results of a cross join by using a WHERE clause.

[edit] Outer joins


An outer join does not require each record in the two joined tables to have a matching record. The joined table retains each recordeven if no other matching record exists. Outer joins subdivide further into left outer joins, right outer joins, and full outer joins, depending on which table(s) one retains the rows from (left, right, or both). (In this case left and right refer to the two sides of the JOIN keyword.) No implicit join-notation for outer joins exists in standard SQL.
[edit] Left outer join

The result of a left outer join (or simply left join) for table A and B always contains all records of the "left" table (A), even if the join-condition does not find any matching record in the "right" table (B). This means that if the ON clause matches 0 (zero) records in B, the join will still return a row in the resultbut with NULL in each column from B. This means that a left outer join returns all the values from the left table, plus matched values from the right table (or NULL in case of no matching join predicate). If the right table returns one row and the left table returns more than one matching row for it, the values in the right table will be repeated for each distinct row on the left table. From Oracle 9i onwards the LEFT OUTER JOIN statement can be used as well as (+).[6] For example, this allows us to find an employee's department, but still shows the employee(s) even when they have not been assigned to a department (contrary to the innerjoin example above, where unassigned employees are excluded from the result). Example of a left outer join, with the additional result row italicized:
SELECT * FROM employee LEFT OUTER JOIN department ON employee.DepartmentID = department.DepartmentID;

Employee.LastNam Employee.DepartmentI Department.DepartmentNam Department.DepartmentI e D e D

Jones Rafferty Robinson Smith John Steinberg

33 31 34 34
NULL

Engineering Sales Clerical Clerical


NULL

33 31 34 34
NULL

33

Engineering

33

Oracle 8i and lower supports the alternate syntax:


SELECT * FROM employee, department WHERE employee.DepartmentID = department.DepartmentID(+)

Sybase supports the alternate syntax:


SELECT * FROM employee, department WHERE employee.DepartmentID *= department.DepartmentID

[edit] Right outer join

A right outer join (or right join) closely resembles a left outer join, except with the treatment of the tables reversed. Every row from the "right" table (B) will appear in the joined table at least once. If no matching row from the "left" table (A) exists, NULL will appear in columns from A for those records that have no match in B. A right outer join returns all the values from the right table and matched values from the left table (NULL in case of no matching join predicate). For example, this allows us to find each employee and his or her department, but still show departments that have no employees. Below is shown an example of right outer join, with the additional result row italicized:
SELECT * FROM employee RIGHT OUTER JOIN department ON employee.DepartmentID = department.DepartmentID;

Employee.LastNam Employee.DepartmentI Department.DepartmentNam Department.DepartmentI e D e D Smith Jones Robinson Steinberg Rafferty 34 33 34 33 31 Clerical Engineering Clerical Engineering Sales 34 33 34 33 31

NULL

NULL

Marketing

35

In practice, explicit right outer joins are rarely used, since they can always be replaced with left outer joins (with the table order switched) and provide no additional functionality. The result above is produced also with a left outer join:
SELECT * FROM department LEFT OUTER JOIN employee ON employee.DepartmentID = department.DepartmentID;

[edit] Full outer join

Conceptually, a full outer join combines the effect of applying both left and right outer joins. Where records in the FULL OUTER JOINed tables do not match, the result set will have NULL values for every column of the table that lacks a matching row. For those records that do match, a single row will be produced in the result set (containing fields populated from both tables). For example, this allows us to see each employee who is in a department and each department that has an employee, but also see each employee who is not part of a department and each department which doesn't have an employee. Example full outer join:
SELECT * FROM employee FULL OUTER JOIN department ON employee.DepartmentID = department.DepartmentID;

Employee.LastNam Employee.DepartmentI Department.DepartmentNam Department.DepartmentI e D e D Smith Jones Robinson John Steinberg Rafferty
NULL

34 33 34
NULL

Clerical Engineering Clerical


NULL

34 33 34
NULL

33 31
NULL

Engineering Sales Marketing

33 31 35

Some database systems (like MySQL) do not support this functionality directly, but they can emulate it through the use of left and right outer joins and unions. The same example can appear as follows:

SELECT * FROM employee LEFT JOIN department ON employee.DepartmentID = department.DepartmentID UNION SELECT * FROM employee RIGHT JOIN department ON employee.DepartmentID = department.DepartmentID;

SQLite does not support right join, so outer join can be emulated as follows:
SELECT employee.*, department.* FROM employee LEFT JOIN department ON employee.DepartmentID = department.DepartmentID UNION ALL SELECT employee.*, department.* FROM department LEFT JOIN employee ON employee.DepartmentID = department.DepartmentID WHERE employee.DepartmentID IS NULL;

[edit] Self-join
A self-join is joining a table to itself.[7] This is best illustrated by an example.
[edit] Example

A query to find all pairings of two employees in the same country is desired. If there were two separate tables for employees and a query which requested employees in the first table having the same country as employees in the second table, a normal join operation could be used to find the answer table. However, all the employee information is contained within a single large table.[8] Consider a modified Employee table such as the following:
Employee Table EmployeeID LastName 123 124 145 201 305 Rafferty Jones Steinberg Country Australia Australia Australia DepartmentID 31 33 33 34 34

Robinson United States Smith Germany

306

John

Germany

NULL

An example solution query could be as follows:


SELECT F.EmployeeID, F.LastName, S.EmployeeID, S.LastName, F.Country FROM Employee F INNER JOIN Employee S ON F.Country = S.Country WHERE F.EmployeeID < S.EmployeeID ORDER BY F.EmployeeID, S.EmployeeID;

Which results in the following table being generated.


Employee Table after Self-join by Country EmployeeID LastName EmployeeID LastName Country 123 123 124 305 Rafferty Rafferty Jones Smith 124 145 145 306 Jones Australia

Steinberg Australia Steinberg Australia John Germany

For this example:


F and S are aliases for the first and second copies of the employee table.
The condition

F.Country = S.Country excludes pairings between employees in F.EmployeeID < S.EmployeeID excludes pairings where the

different countries. The example question only wanted pairs of employees in the same country.

The condition

EmployeeID s are the same.

F.EmployeeID < S.EmployeeID also excludes duplicate pairings. Without it,


the following less useful table would be generated (the table below displays only the "Germany" portion of the result):

EmployeeID LastName EmployeeID LastName Country

305 305 306 306

Smith Smith John John

305 306 305 306

Smith John Smith John

Germany Germany Germany Germany

Only one of the two middle pairings is needed to satisfy the original question, and the topmost and bottommost are of no interest at all in this example.

[edit] Merge rows


To be able to do a select so as to merge multiple rows into 1 row : "group_concat notation". MySQL uses the group_concat keyword to achieve that goal, and PostgreSQL 9.0 has the string_agg function. Versions before 9.0 required the use of something like
array_to_string(array_agg(value),', ')

or the creation of an aggregate function.


Using the Employee Table: LastName DepartmentID Rafferty Jones Steinberg Robinson Smith John 31 33 33 34 34
NULL

to achieve the following results Table DepartmentID


NULL

LastNames John

31 33 34

Rafferty Jones, Steinberg Robinson, Smith

[edit] MySQL
SELECT DepartmentID, group_concat(LastName) AS LastNames FROM employee GROUP BY DepartmentID;

[edit] PostgreSQL

First the function _group_concat and aggregate group_concat need to be created before that query can be possible.
CREATE OR REPLACE FUNCTION _group_concat(text, text) RETURNS text AS $$ SELECT CASE WHEN $2 IS NULL THEN $1 WHEN $1 IS NULL THEN $2 ELSE $1 operator(pg_catalog.||) ', ' operator(pg_catalog.||) $2 END $$ IMMUTABLE LANGUAGE SQL; error// JOIN SQL CREATE AGGREGATE group_concat ( BASETYPE = text, SFUNC = _group_concat, STYPE = text ); SELECT DepartmentID, group_concat(LastName) AS LastNames FROM employee GROUP BY DepartmentID;

As for version 9.0:


SELECT DepartmentID, string_agg(LastName, ', ') AS LastNames FROM employee GROUP BY DepartmentID;

[edit] Microsoft T-SQL

For versions prior to Microsoft SQL Server 2005, the function group_concat must be created as a user-defined aggregate function before that query can be possible, shown here in C#.
using System; using System.Collections.Generic; using System.Data.SqlTypes;

using System.IO; using Microsoft.SqlServer.Server; [Serializable] [SqlUserDefinedAggregate(Format.UserDefined, MaxByteSize=8000)] public struct group_concat : IBinarySerialize{ private List values; public void Init() { this.values = new List(); } public void Accumulate(SqlString value) this.values.Add(value.Value); } {

public void Merge(strconcat value) { this.values.AddRange(value.values.ToArray()); } public SqlString Terminate() { return new SqlString(string.Join(", ", this.values.ToArray())); } public void Read(BinaryReader r) { int itemCount = r.ReadInt32(); this.values = new List(itemCount); for (int i = 0; i < itemCount; i++) this.values.Add(r.ReadString()); } } public void Write(BinaryWriter w) { w.Write(this.values.Count); foreach (string s in this.values) w.Write(s); } } }

Then you can use the following query:


SELECT DepartmentID, dbo.group_concat(LastName) AS LastNames FROM employee GROUP BY DepartmentID;

From version 2005, one can accomplish this task using FOR XML PATH:
SELECT DepartmentID, STUFF( (SELECT ',' + LastName FROM ( SELECT LastName FROM employee e2 WHERE e1.DepartmentID=e2.DepartmentID OR (e1.DepartmentID IS NULL AND e2.DepartmentID IS NULL) ) t1

ORDER BY LastName FOR XML PATH('') ) ,1,1, '' ) AS LastNames FROM employee e1 GROUP BY DepartmentID

[edit] Alternatives
The effect of outer joins can also be obtained using correlated subqueries. For example
SELECT employee.LastName, employee.DepartmentID, department.DepartmentName FROM employee LEFT OUTER JOIN department ON employee.DepartmentID = department.DepartmentID;

can also be written as


SELECT employee.LastName, employee.DepartmentID, (SELECT department.DepartmentName FROM department WHERE department.DepartmentID = employee.DepartmentID ) AS DepartmentName FROM employee;

[edit] Implementation
Much work in database-systems has aimed at efficient implementation of joins, because relational systems commonly call for joins, yet face difficulties in optimising their efficient execution. The problem arises because inner joins operate both commutatively and associatively. In practice, this means that the user merely supplies the list of tables for joining and the join conditions to use, and the database system has the task of determining the most efficient way to perform the operation. A query optimizer determines how to execute a query containing joins. A query optimizer has two basic freedoms:
1. Join order: Because it joins functions commutatively and associatively, the order in which the system joins tables does not change the final result-set of the query. However, join-order does have an enormous impact on the cost of the join operation, so choosing the best join order becomes very important. 2. Join method: Given two tables and a join condition, multiple algorithms can produce the resultset of the join. Which algorithm runs most efficiently depends on the sizes of the input tables, the number of rows from each table that match the join condition, and the operations required by the rest of the query.

Many join-algorithms treat their inputs differently. One can refer to the inputs to a join as the "outer" and "inner" join operands, or "left" and "right", respectively. In the case of nested loops, for example, the database system will scan the entire inner relation for each row of the outer relation. One can classify query-plans involving joins as follows:[9]

left-deep using a base table (rather than another join) as the inner operand of each join in the plan right-deep using a base table as the outer operand of each join in the plan bushy neither left-deep nor right-deep; both inputs to a join may themselves result from joins

These names derive from the appearance of the query plan if drawn as a tree, with the outer join relation on the left and the inner relation on the right (as convention dictates).
[edit] Join algorithms

Three fundamental algorithms exist for performing a join operation: Nested loop join, Sortmerge join and Hash join.

[edit] See also

Join (relational algebra)

[edit] Notes
1. 2. 3. 4. 5. 6. ^ "SQL JOIN - SQL Tutorial". www.sql-tutorial.net. http://www.sql-tutorial.net/SQL-JOIN.asp. ^ Simplifying Joins with the USING Keyword ^ Ask Tom "Oracle support of ANSI joins." Back to basics: inner joins Eddie Awad's Blog ^ Why SQL Server Doesnt Support Natural Join Syntax ^ SQL CROSS JOIN ^ Oracle Left Outer Join. "Oracle Left Outer Join". Oracle Tips. Burleson Consulting. http://www.dba-oracle.com/tips_oracle_left_outer_join.htm. Retrieved 15 July 2011. 7. ^ Shah 2005, p. 165 8. ^ Adapted from Pratt 2005, pp. 1156 9. ^ Yu & Meng 1998, p. 213

[edit] References
This article includes a list of references, but its sources remain unclear because it has insufficient inline citations. Please help to improve this article by introducing more precise citations. (April 2009)

Pratt, Phillip J (2005), A Guide To SQL, Seventh Edition, Thomson Course Technology, ISBN 9780619216740 Shah, Nilesh (2005) [2002], Database Systems Using Oracle - A Simplified Guide to SQL and PL/SQL Second Edition (International ed.), Pearson Education International, ISBN 0131911805

Yu, Clement T.; Meng, Weiyi (1998), Principles of Database Query Processing for Advanced Applications, Morgan Kaufmann, ISBN 9781558604346, http://books.google.com/?id=aBHRDhrrehYC, retrieved 2009-03-03

[edit] External links

Specific to products o Sybase ASE 15 Joins o MySQL 5.5 Joins o PostgreSQL Join with Query Explain o PostgreSQL 8.3 Joins o Joins in Microsoft SQL Server o Joins in MaxDB 7.6 o Joins in Oracle 11g General o A Visual Explanation of SQL Joins o Another visual explanation of SQL joins, along with some set theory o SQL join types classified with examples o An alternative strategy to using FULL OUTER JOIN [hide]v d eSQL

Versions SQL-86 SQL-89 SQL-92 SQL:1999 SQL:2003 SQL:2008

Keywords

CREATE

DELETE FROM HAVING INSERT JOIN MERGE NULL ORDER BY

PREPARE SELECT TOP TRUNCATE UNION UPDATE WHERE

Related

Edgar Codd Relational database

Retrieved from "http://en.wikipedia.org/w/index.php?title=Join_(SQL)&oldid=454986043" View page ratings

Rate this page


What's this? Trustworthy

Objective

Complete

Well-written

I am highly knowledgeable about this topic (optional) Submit ratings Saved successfully Your ratings have not been submitted yet

Potrebbero piacerti anche