Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Shaun E on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

IF Statement ......... Help!

Status
Not open for further replies.

Azita79

Programmer
Jan 30, 2003
41
US
Hi All,

My tblclient has both individual clients and company clients data

It has the following data

Pkclient
FirstName
LastName
CompanyName
Etc …

I want to select the companyName if there is one, otherwise select FirstName and LastName.

Here is my Pseudocode: If CompanyName is not null then select companyName
Else select (Firstname & ‘ ‘ & LastName)

But I don’t know how to write the IF statement in SQL

Any help would be greatly appreciated

Azita
 
Hi,

U can do something like this

Select Isnull(CompanyName, FirstName + ' ' + LastName) From TBL

Or
Select Case CompnayName when NULL then FirstName + ' ' + LastName Else CompanyName End from TBL



Sunil
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top