Inner Join example in MySQL

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,


product_id product_name
1 Car
2 Truck
3 Scooter
4 Bicycle


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

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>