SQL how to output two columns as a single column in a query


Its something that is very easy to do in SQL Server, to output two columns of the same type (nvarchar) as a single column (for example joining firstnames and lastname columns into a single displayname field)

SELECT firstnames + ‘ ‘ + lastname AS displayname FROM table

the problem is, in MySQL, you cant do this. You can however join fields using the CONCAT command

SELECT CONCAT(firstnames, ‘ ‘, lastname) AS displayname FROM table

Add Comment

Leave a Reply




Get in touch

I'm available on just about every social media platform out there as RMTWeb.