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
 SQL Server 2005 Forums
 Transact-SQL (2005)
 Need select query

Author  Topic 

kamal.A
Yak Posting Veteran

70 Posts

Posted - 2009-04-17 : 04:45:37
Hi All,

I have the following fields (for example) in my test table.

Name adress Designation Dateofbirth


I have to display all the above fields in thru my query, and i will given the Designation and DateOfBirth fields. If both the fields are match the it will display all the relevant record, if any one field information is wrong then how can i identif which field is not match from sql query

pls help me

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2009-04-17 : 05:02:50

1
select Name, adress,Designation, Dateofbirth from your_table
where Designation='some value', Dateofbirth='some date'

2
select Name, adress,
case when Designation<>'some value' then 'not found' else Desingation end,
case when Dateofbirth <>'some date' then 'not found' else Dateofbirth end
from your_table



Madhivanan

Failing to plan is Planning to fail
Go to Top of Page

bklr
Master Smack Fu Yak Hacker

1693 Posts

Posted - 2009-04-17 : 06:07:29
quote:
Originally posted by madhivanan


1
select Name, adress,Designation, Dateofbirth from your_table
where Designation='some value', AND Dateofbirth='some date'

2
select Name, adress,
case when Designation<>'some value' then 'not found' else Desingation end,
case when Dateofbirth <>'some date' then 'not found' else Dateofbirth end
from your_table



Madhivanan

Failing to plan is Planning to fail

Go to Top of Page

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2009-04-17 : 07:13:06
quote:
Originally posted by bklr

quote:
Originally posted by madhivanan


1
select Name, adress,Designation, Dateofbirth from your_table
where Designation='some value', AND Dateofbirth='some date'

2
select Name, adress,
case when Designation<>'some value' then 'not found' else Desingation end,
case when Dateofbirth <>'some date' then 'not found' else Dateofbirth end
from your_table



Madhivanan

Failing to plan is Planning to fail




Thanks

Madhivanan

Failing to plan is Planning to fail
Go to Top of Page
   

- Advertisement -