RMTWeb

View Original

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 tablethe problem is, in MySQL, you cant do this. You can however join fields using the CONCAT commandSELECT CONCAT(firstnames, ' ', lastname) AS displayname FROM table