user2747098
user2747098

Reputation: 3

Select 2 columns and the display those to columns as 1 column

I need a query that will select 2 columns in the same table and then display those to columns as 1 column.

I have this table..

fname   | lname
john    | doe
jane    | doe

I want to display it like this..

name      |
john doe  |
jane doe  |

Upvotes: 0

Views: 96

Answers (2)

gvee
gvee

Reputation: 17161

SQL Server 2008 or earlier:

SELECT fname + ' ' + lname As name
FROM   users

SQL Server 2012 onwards and MySQL

SELECT Concat(fname, ' ', lname) As name
FROM   users

Upvotes: 0

David Hedlund
David Hedlund

Reputation: 129792

Assuming SQL Server:

SELECT fname + ' ' + lname FROM users

In MySQL Server:

SELECT concat(fname, " ", lname) FROM users

Upvotes: 5

Related Questions