Hello Friends,
today I am going to teach you how do we fetch data from two tables simultaneously.
So, ready ?
a friend of mine just put me an email and ask me how does he fetch records from two tables.
here are the column names from table 1:
He had two tables one has product name, description etc and other has product price.
He wanted to show product_price , product description and product name where product_id is same in both tables.
Table_1
product_id, product_description, product_name, product_snd_description.
Column names from Table_2
product_id, product_price
Here is the solution:
SELECT t1.product_snd_description, t1.product_description, t1.product_name , t2.product_price FROM table_1 as t1
INNER JOIN table_2 as t2 ON t2.product_id = t1.product_id
above query gave him the exact result that he was looking for.
today I am going to teach you how do we fetch data from two tables simultaneously.
So, ready ?
a friend of mine just put me an email and ask me how does he fetch records from two tables.
here are the column names from table 1:
He had two tables one has product name, description etc and other has product price.
He wanted to show product_price , product description and product name where product_id is same in both tables.
Table_1
product_id, product_description, product_name, product_snd_description.
Column names from Table_2
product_id, product_price
Here is the solution:
SELECT t1.product_snd_description, t1.product_description, t1.product_name , t2.product_price FROM table_1 as t1
INNER JOIN table_2 as t2 ON t2.product_id = t1.product_id
above query gave him the exact result that he was looking for.
No comments:
Post a Comment