Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 Query

Author  Topic 

immad
Posting Yak Master

230 Posts

Posted - 2013-04-22 : 00:55:12
my data is like that

Company ID - Branch ID - Department ID - Employee ID - Employee Name
--1 ------------- 1 ------------ 52 --------- 5211 ----------- abc
--1 ------------- 2 ------------ 32 --------- 2689 ----------- def

i want a query that when i select branch id '1' employeeid its only show that branch employee data and when i select branch id '2' employeeid then it didnt show any data.

please help me i am new in sql server 2005.



immad uddin ahmed

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2013-04-22 : 00:59:31
its a simple select. have a look at syntax of select with where condition in MSDN

http://msdn.microsoft.com/en-IN/library/ms189499.aspx

------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/
https://www.facebook.com/VmBlogs
Go to Top of Page

bandi
Master Smack Fu Yak Hacker

2242 Posts

Posted - 2013-04-22 : 01:01:41
Can you explain in detail and also provide expected output...
If branchid =1 then output should be
Company ID - Branch ID - Department ID - Employee ID - Employee Name
1 ------------- 1 ------------ 52 --------- 5211 ----------- abc

if branchid =2 then output should be
Employee ID
5211

Is it your requirement? What should be the output for the case of neither 1 nor 2?

--
Chandu
Go to Top of Page

immad
Posting Yak Master

230 Posts

Posted - 2013-04-22 : 01:29:00
If branchid =1 then output should be
Company ID - Branch ID - Department ID - Employee ID - Employee Name
1 ------------- 1 ------------ 52 --------- 5211 ----------- abc

if branchid =2 then output should be
Company ID - Branch ID - Department ID - Employee ID - Employee Name
1 ------------- 2 ------------ 32 --------- 2689----------- def

i want two query one for branch id 1 and another for branch id 2

immad uddin ahmed
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2013-04-22 : 01:37:51
[code]
DECLARE @branchid int
SELECT *
FROM Table
WHERE branchid = @branchid
[/code]

------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/
https://www.facebook.com/VmBlogs
Go to Top of Page
   

- Advertisement -