INNER JOIN example

Example:

Consider the following two tables,
(a) CUSTOMERS table is as follows:
| ID | NAME     |
+----+----------+
|  1 | Ramesh   |
|  2 | Khilan   |
(b) Another table is ORDERS as follows:
|OID  | DATE  | C_ID | AMOUNT |
+-----+-------+------+--------+
| 102 | 10-08 |    3 |   3000 |
| 100 | 10-08 |    3 |   1500 |
| 101 | 11-20 |    2 |   1560 |
Now, let us join these two tables using INNER JOIN as follows:
SQL> SELECT  ID, NAME, AMOUNT, DATE
     FROM CUSTOMERS, ORDERS;
This would produce the following result:
| ID | NAME     | AMOUNT | DATE  |
+----+----------+--------+-------+
|  1 | Ramesh   |   3000 | 10-08 |
|  1 | Ramesh   |   1500 | 10-08 |
|  1 | Ramesh   |   1560 | 11-20 |
|  2 | Khilan   |   3000 | 10-08 |
|  2 | Khilan   |   1500 | 10-08 |
|  2 | Khilan   |   1560 | 11-20 |

Следи за CodeGalaxy

Мобильное приложение Beta

Get it on Google Play
Обратная Связь
Продолжайте изучать
сниппеты с SQL
Cosmo
Зарегистрируйся сейчас
или Подпишись на будущие тесты