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 IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

select statement that can return null values

Status
Not open for further replies.

fpower

MIS
Aug 12, 2003
54
US
Hi everyone,

I am new to sql so any help is appreciated.
I have a table with 6 columns, ID, model, Title, Description, Options, and Items.
When I run the following select statement it returns a NULL value.

Select ID, model + '<br>' + title + '<br>' + description + '<br>' + options + '<br>' + items
AS FullDescription
Where ID = 123

When I input data in all the fields it works just fine. So I know the NULL return is due to the fact that some fields have a NULL value.

How can I do a select statement that will ignore NULL values, and return data even if some fields have a NULL value? I have tried isnull and coalesce, but not done so successfully.
Any examples/help would help a great deal.
Thanks in advance.
 
Select ID, ISNULL(model,'') + '<br>' + ISNULL(title,'') + '<br>' + ISNULL(description,'') + '<br>' + ISNULL(options,'') + '<br>' + ISNULL(items,'')
AS FullDescription
Where ID = 123

or

Select ID, ISNULL(model + '<br>','') + ISNULL(title + '<br>','') + description + '<br>' + options + '<br>' + items
AS FullDescription
Where ID = 123

etc. to avoid extra <br> in the final result.

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top