Language:EN
Pages: 2
Rating : ⭐⭐⭐⭐⭐
Price: $10.99
Page 1 Preview
customers where would produce the following result

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

You are viewing 1/3rd of the document.Purchase the document to get full access instantly

Immediately available after payment
Both online and downloadable
No strings attached
How It Works
Login account
Login Your Account
Place in cart
Add to Cart
send in the money
Make payment
Document download
Download File
img

Uploaded by : Gareth Deacy

PageId: ELI3E61B72