Click here to Skip to main content
15,918,742 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
farmerregistration table as follows


farmerid Firstname Region Zone Section Village

1055662 Lacina OUNGAlo Diawala Nord Diwala

transaction table as follows


transactionid Qty Price Paid Due

1055662 1 200 200 100

from the above i want output as follows

farmerid Firstname Region Zone Section Qty Price Paid
1055662 Lacina OUNGALo Diawala Nord 1 200 200


how to use join and get the above output in sql server

What I have tried:

farmerregistration table as follows


farmerid Firstname Region Zone Section Village

1055662 Lacina OUNGAlo Diawala Nord Diwala

transaction table as follows


transactionid Qty Price Paid Due

1055662 1 200 200 100

from the above i want output as follows

farmerid Firstname Region Zone Section Qty Price Paid
1055662 Lacina OUNGALo Diawala Nord 1 200 200


how to use join and get the above output in sql server
Posted
Updated 20-Jun-18 20:43pm

1 solution

Say, you have two tables
name_info(id int, name string);
visit_info (id int, entry_date date, departure_date date )

The query would be:
SQL
SELECT a.id, a.name, b.id, b.entry_date, b.departure_date FROM name_info a, visit_info b WHERE a.id=b.id
-- or
SELECT a.id, a.name, b.id, b.entry_date, b.departure_date FROM name_info a JOIN visit_info b ON( a.id=b.id )


Let us know if this is not enough.
 
Share this answer
 

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