Inner Join example in MySQL

Rating 3.50 out of 5

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:

  1. Common mistakes and points to remember in MySQL

Leave a Reply

 

 

 

You can use these HTML tags

<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>