I have two tables:
This is table1:
product_id|product_desc|product_name|product_s_desc
This is table2:
product_price_id|product_id|product_price
Now I want to fetch data from these tables. product_id is same in both tables.
I want to fetch
product_s_descproduct_descproduct_name AND product_price from other table.Please help me do this.
I'm assuming you have a field named product_price in your second table (you didn't list it):
SELECT t1.product_s_desc, t1.product_desc, t1.product_name, t2.product_price
FROM table1 t1
INNER JOIN table2 t2 ON t2.product_id = t1.product_id
You should check out the MySQL manual regarding JOINS, as this is a very basic part of writing SQL queries. You might also consider adding an index on table2 for the product_id field to make the query run faster.
Select * from table1 join table2 on table1.productid = table2.productid
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With