SQL Server Forums
Profile | Register | Active Topics | Members | Search | Forum FAQ
 
Register Now and get your question answered!
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 Query
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

immad
Posting Yak Master

Pakistan
218 Posts

Posted - 04/22/2013 :  00:55:12  Show Profile  Reply with Quote
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

Edited by - immad on 04/22/2013 00:59:19

visakh16
Very Important crosS Applying yaK Herder

India
52309 Posts

Posted - 04/22/2013 :  00:59:31  Show Profile  Reply with Quote
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
Flowing Fount of Yak Knowledge

India
2202 Posts

Posted - 04/22/2013 :  01:01:41  Show Profile  Reply with Quote
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

Pakistan
218 Posts

Posted - 04/22/2013 :  01:29:00  Show Profile  Reply with Quote
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

Edited by - immad on 04/22/2013 01:31:03
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

India
52309 Posts

Posted - 04/22/2013 :  01:37:51  Show Profile  Reply with Quote

DECLARE @branchid int
SELECT *
FROM Table
WHERE branchid = @branchid


------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/
https://www.facebook.com/VmBlogs
Go to Top of Page
  Previous Topic Topic Next Topic  
 New Topic  Reply to Topic
 Printer Friendly
Jump To:
SQL Server Forums © 2000-2009 SQLTeam Publishing, LLC Go To Top Of Page
This page was generated in 0.06 seconds. Powered By: Snitz Forums 2000