user3510027
user3510027

Reputation:

Join attributes in sql query

I want to join few attributes in select statement using MySQL

SELECT 
        (Cast(n_socio As varchar), ' - ', nombre, ' ', apellidos) As DisplayItem,
        N_socio 
FROM     
        usuarios 
ORDER BY 
        n_socio

Upvotes: 0

Views: 58

Answers (2)

zkanoca
zkanoca

Reputation: 9928

You are missing CONCAT function.

SELECT 
        CONCAT(Cast(n_socio As varchar), ' - ', nombre, ' ', apellidos) As DisplayItem,
        N_socio 
FROM     
        usuarios 
ORDER BY 
        n_socio

Upvotes: 1

Sadikhasan
Sadikhasan

Reputation: 18598

USE MySQL CONCAT function like

SELECT CONCAT((Cast(n_socio AS varchar),' - ',nombre ,' ',apellidos)) AS DisplayItem,
       N_socio
FROM usuarios
ORDER BY n_socio

Upvotes: 1

Related Questions