Click here to Skip to main content
15,881,281 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
hi
i have two table both have same fields one have two fields different called price and total
i am join both tables and want to fetch some fields from first table and price and total from second table let i have two rows for a particular order then my result shows 4 rows (2+2 from both) but i want only two rows
Posted
Updated 31-Oct-12 21:37pm
v2
Comments
Street Racers 1-Nov-12 2:43am    
Use "inner join" based on the primary key.
damodara naidu betha 1-Nov-12 3:08am    
please post your tables design along with sample data.

1 solution

First table table1
OrderId,
OrderName,
Date

Second table table2
OrderId,
Price,
Total

C#
Select OrderId, price, total from table1 t1
inner join table2 t2 on t1.Orderid=t2.OrderId


Now this will give me only 3 columns. you can write whatever fields you want like this
 
Share this answer
 
Comments
Mohamed Mitwalli 1-Nov-12 3:57am    
5+
damodara naidu betha 1-Nov-12 10:12am    
5+

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900