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)
 sql query problem

Author  Topic 

desikankannan
Posting Yak Master

152 Posts

Posted - 2010-08-26 : 23:15:16
Hi,
below the my query iam search a record from table,i want to get the
record by code or description
if its null i want to show only one record

select comcode,comdesc from ascommoditytype where comcode like'null%' or comdesc like'ELECTRONICS%'

Desikankannan

pk_bohra
Master Smack Fu Yak Hacker

1182 Posts

Posted - 2010-08-27 : 00:26:28
Is this you are looking for ?

select distinct comcode,comdesc from ascommoditytype where comcode is null or comdesc like'ELECTRONICS%'.

If your requirement is different then post some sample data and expected output for us to understand your requirement clearly.

Regards,
Bohra

I am here to learn from Masters and help new bees in learning.
Go to Top of Page

kunal.mehta
Yak Posting Veteran

83 Posts

Posted - 2010-08-27 : 08:51:13
Provide sample data and what is the reqt.
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2010-08-28 : 01:12:09
quote:
Originally posted by desikankannan

Hi,
below the my query iam search a record from table,i want to get the
record by code or description
if its null i want to show only one record

select comcode,comdesc from ascommoditytype where comcode like'null%' or comdesc like'ELECTRONICS%'

Desikankannan


which is record you want to show when its null? some default value?

------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/

Go to Top of Page
   

- Advertisement -