Over 10 Million Study Resources Now at Your Fingertips


Download as :
Rating : ⭐⭐⭐⭐⭐
Price : $10.99
Language:EN
Pages: 2

Customers where would produce the following result

Example:
Consider the following two tables, (a) CUSTOMERS table is as follows:

+----+----------+-----+-----------+----------+ | ID | NAME | AGE | ADDRESS | SALARY | +----+----------+-----+-----------+----------+ |1|Ramesh|32|Ahmedabad|2000.00| |2|Khilan|25|Delhi|1500.00| |3| kaushik |23|Kota|2000.00| |4|Chaitali|25|Mumbai|6500.00| |5|Hardik|27|Bhopal|8500.00| |6|Komal|22| MP |4500.00| |7|Muffy|24|Indore|10000.00| +----+----------+-----+-----------+----------+

This would produce the following result:

+------+----------+--------+---------------------+ | ID | NAME | AMOUNT | DATE | +------+----------+--------+---------------------+ |1|Ramesh| NULL | NULL | |2|Khilan|1560|2009-11-2000:00:00| |3| kaushik |3000|2009-10-0800:00:00| |3| kaushik |1500|2009-10-0800:00:00| |4|Chaitali|2060|2008-05-2000:00:00| |5|Hardik| NULL | NULL | |6|Komal| NULL | NULL | |7|Muffy| NULL | NULL | |3| kaushik |3000|2009-10-0800:00:00| |3| kaushik |1500|2009-10-0800:00:00| |2|Khilan|1560|2009-11-2000:00:00| |4|Chaitali|2060|2008-05-2000:00:00|

ON CUSTOMERS.ID = ORDERS.CUSTOMER_ID
UNION ALL
SELECT ID, NAME, AMOUNT, DATE
FROM CUSTOMERS
RIGHT JOIN ORDERS
ON CUSTOMERS.ID = ORDERS.CUSTOMER_ID

SELF JOIN
The SQL SELF JOIN is used to join a table to itself as if the table were two tables, temporarily renaming at least one table in the SQL statement.

Example:
Consider the following two tables, (a) CUSTOMERS table is as follows:

+----+----------+-----+-----------+----------+ | ID | NAME | AGE | ADDRESS | SALARY | +----+----------+-----+-----------+----------+ |1|Ramesh|32|Ahmedabad|2000.00| |2|Khilan|25|Delhi|1500.00| |3| kaushik |23|Kota|2000.00| |4|Chaitali|25|Mumbai|6500.00| |5|Hardik|27|Bhopal|8500.00| |6|Komal|22| MP |4500.00| |7|Muffy|24|Indore|10000.00| +----+----------+-----+-----------+----------+

TUTORIALS POINT
Simply Easy Learning

How It Works
Login account
Login Your Account
Add to cart
Add to Cart
Payment
Make payment
Document download
Download File
PageId: ELI3E61B72
img
Uploaded by :
veDRMvAd
Page 1 Preview
customers where would produce the following result
Sell Your Old Documents & Earn Wallet Balance