Categories:
.NET (357)
C (330)
C++ (183)
CSS (84)
DBA (2)
General (7)
HTML (4)
Java (574)
JavaScript (106)
JSP (66)
Oracle (114)
Perl (46)
Perl (1)
PHP (1)
PL/SQL (1)
RSS (51)
Software QA (13)
SQL Server (1)
Windows (1)
XHTML (173)
Other Resources:
What are the different types of joins? What is the difference between them
What are the different types of joins? What is the difference between them ?
✍: Guest
INNER JOIN
Inner join shows matches only when they exist in both tables.Example, in the below SQL
there are two tables Customers and Orders and the inner join in made on Customers
Customerid and Orders Customerid.So this SQL will only give you result with customers
who have orders.If the customer does not have order it will not display that record.
SELECT Customers.*, Orders.* FROM Customers INNER JOIN Orders ON
Customers.CustomerID =Orders.CustomerID
LEFT OUTER JOIN
Left join will display all records in left table of the SQL statement.In SQL below customers
with or without orders will be displayed. Order data for customers without orders appears
as NULL values. For example, you want to determine the amount ordered by each
customer and you need to see who has not ordered anything as well. You can also see the
LEFT OUTER JOIN as a mirror image of the RIGHT OUTER JOIN (Is covered in the
next section) if you switch the side of each table.
SELECT Customers.*, Orders.* FROM Customers LEFT OUTER JOIN Orders ON
Customers.CustomerID =Orders.CustomerID
RIGHT OUTER JOIN
Right join will display all records in right table of the SQL statement. In SQL below all
orders with or without matching customer records will be displayed. Customer data for
orders without customers appears as NULL values. For example, you want to determine
if there are any orders in the data with undefined CustomerID values (say, after a conversion
or something like it). You can also see the RIGHT OUTER JOIN as a mirror image of
the LEFT OUTER JOIN if you switch the side of each table.
SELECT Customers.*, Orders.* FROM Customers RIGHT OUTER JOIN Orders
ON Customers.CustomerID =Orders.CustomerID
2007-10-25, 4552👍, 0💬
Popular Posts:
What is hashing? To hash means to grind up, and that's essentially what hashing is all about. The he...
What will be printed as the result of the operation below: main() { int x=5; printf("%d,%d,%d\n",x,x. ..
If we have multiple AFTER Triggers on table how can we define the sequence of the triggers ? If a ta...
Write out a function that prints out all the permutations of a string. For example, abc would give y...
What will be printed as the result of the operation below: #define swap(a,b) a=a+b;b=a-b;a=a-b; void...