AspdotnetCodes.com
Search
Articles
Books
Resources
Asp.Net News
Downloads
Free Tech Magazines
Asp.Net Web Hosting
Archives
Softwares
Newsletter
Suggest Us
Link to Us
Feeds Subscription
Articles
Questions & Answers
Tips & Tricks
 how to write the querry for user belongs to a company to all related branches
Posted by charan on  3/22/2010 12:11:22 AM Category: ADO.NET
Add to my favorites
Email to friend
iam usin sql server 2000, the table are as follows

tbluser
========


username nvarchar(50) pk

usertype nvarchar(50)

companyid nvarchar(50) fk


tblcompany
==========
companyid nvarchar(50) pk
company name nvarchar(50)


tblbranch
========

branchid nvarchar(50) pk

branchname nvarchar(50)
companyid nvarchar(50)
location nvarchar(50)



how to write the querry for user belongs to a company to all related branches


please give the example which helps me.

Post Your Reply Post New Question

 Viewer's Reply
SQL Query Join with Multiple Tables
Answered By Moderator1 on 3/22/2010 8:06:10 AM
Hi,

You can do in 2 ways.

Select * from tblUser a
Inner Join tblcompany b On a.CompanyId=b.CompanyId
Inner Join tblbranch c on b.CompanyId=c.CompanyId
Where c.CompanyId=YourCompanyId

or simply

Select * from tblUser a Where a.CompanyId=YourCompanyId
 
Post Your Reply If you still have problem, post it again under this reply for better response.

 
Sponsored by
Introduction to Software Development
Everything You Know About CSS Is Wrong! - Free 37 Page Preview!
Oracle Magazine