Home > DeveloperSection > Forums > show all total matched records from 2 tables if both tables have one column same
Hugh Jackman
Hugh Jackman

Total Post:52

Points:366
Posted on    May-16-2013 6:53 AM

 MSSQL Server MSSQL Server 
Ratings:


 1 Reply(s)
 690  View(s)
Rate this:
Hi Expert!

I want to get total matched records from 2 tables. Tables and data are as following

tblOrderList_INDIA

Order_ID Product_ID Customer_ID Order_Date
----------------------------------------------------------
1 10001 90001 2013-12-12
2 10002 90002 2013-06-26
3 10003 90003 2013-06-26
4 10009 90001 2013-04-05
5 10015 90123 2013-04-15

tblOrderList_US

Order_ID  Product_ID Customer_ID Order_Date
----------------------------------------------------------
1 10009 90012 2013-04-05
2 10015 90150 2013-06-15
3 10008 90261 2013-09-21

I want to get match customer_id from both table(tblOrderList_INDIA, tblOrderList_US).

Please help.
Thanks in advance!




AVADHESH PATEL

Total Post:604

Points:4228
Posted on    May-16-2013 8:28 AM

Hi Hugh!

Use Inner join to get matching data as following

SELECT ind.Customer_ID as 'Customer_ID'  FROM tblOrderList_INDIA ind inner join tblOrderList_US us on ind.Product_ID = us.Product_ID

Don't want to miss updates? Please click the below button!

Follow MindStick