Murray
Murray

Reputation: 49

How to put a space between two SQL columns after joining them?

I have joined two columns, first name\last name into one and named it with an alias which is all good. But how do I put a space between first and last name?

au.first_name || au.last_name Name

Upvotes: 4

Views: 20581

Answers (4)

siri
siri

Reputation: 21

if your working on sql server try the below 2

select au.first_name+ '  '+ au.last_name as Name from yourtablename

but in this case if you have null values in either of the columns then none of the records will be shown, instead Null will be shown.

or use

select concat(au.first_name, '  ', au.last_name) as Name from yourtablename-

unlike +, concat will replace null with an empty string. so atleast one name will be shown.

hope this helps such queries being googled

Upvotes: 2

user3311270
user3311270

Reputation: 1

--Combining the Client Address in one column and have comma separating the value.

(SELECT (Client.STREET+','+Client.CITY+','+Client.STATE+','+Client.ZIP))AS ClientAddress,

Upvotes: -3

No'am Newman
No'am Newman

Reputation: 6477

You can add the space in the same manner that you have concatenated the first and last names,

au.first_name ||' ' || au_last_name name

Upvotes: 4

John Woo
John Woo

Reputation: 263693

here:

au.first_name || ' ' || au.last_name Name

Upvotes: 6

Related Questions