Suppose we have two different tables in Database, one having product ID and product name and the other having product ID and price, as shown below,
Table_1
| product_id | product_name | |
| 1 | Car | |
| 2 | Truck | |
| 3 | Scooter | |
| 4 | Bicycle |
Table_2
| product_id | product_price | |
| 1 | 50000 | |
| 2 | 60000 | |
| 3 | 5000 | |
| 4 | 1000 |
then to show the product names with their price, we can write an SQL statement (Inner Join) like this,
SELECT a.product_name, b.product_price FROM Table_1 a, Table_2 WHERE a.product_id=b.product_id;
This would give you the result as,
| a.product_name | b.product_price | |
| Car | 50000 | |
| Truck | 60000 | |
| Scooter | 5000 | |
| Bicycle | 1000 |
Related posts: