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

How to concatenate two or more DB columns into one SELECT column

Status
Not open for further replies.

HFChristie

Programmer
Oct 25, 2002
61
US
How do I code a SELECT statement so that the values in two columns are combined into one result?

For instance;
SELECT (col_a || col_b) AS col_a_b
FROM table_a

(col_a and col_b are character data type)

I thought "+" could be used, but thats returning data type error. I also tried | and ||, but they both fail.

Also, if you know this, do you know how to have it return a value even if one of the columns is NULL?

Thank you
 
Use the ampersand (&) for strings.
col_a & col_b

To get past Null, use an empty string ""
col_a & col_b & ""

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top