i have 3 tables
|| user ||
||------------------------------------||
|| name || lastname || documentoU ||
|| Andres || Perez || 123456 ||
|| user_info_user ||
||-----------------------------------------------||
|| id || documentoU || idInfo || infoValor ||
|| 1 || 123456 || 1 || 123456789 ||
|| 2 || 123456 || 1 || 987654321 ||
|| 3 || 123456 || 2 ||
email@email.com ||
|| info_user ||
||----------------------||
|| idInfo || name ||
|| 1 || phone ||
|| 2 || email ||
El resultado de usuario_info_usuario es
|| documentoU || name || lastname || infoValor ||
||---------------------------------------------------||
|| 123456 || Andres || Perez || 123456789 ||
|| 123456 || Andres || Perez || 987654321 ||
|| 123456 || Andres || Perez ||email@email.com||
I need it to be like that
|| documentoU || name || lastname || a || b || c ||
||------------------------------------------------------------------------||
|| 123456 || Andres || Perez ||123456789||987654321||cor@correo.com||
to get the values of the rows in PHP
if I use group by, only the first row remains
i have its SQL:
SELECT u.num_documento_usuario,
u.nombre,
u.apellido,
u.tipo_documento,
coalesce((case when i.id_info_usuario = '2' then i.info_usuario_valor end), NULL) as A,
coalesce((case when i.id_info_usuario = '11' then i.info_usuario_valor end), NULL) as B
FROM usuario AS u
INNER JOIN usuario_info_usuario AS i
ON i.num_documento_usuario = u.num_documento_usuario
INNER JOIN info_usuario AS inf ON inf.id_info_usuario=i.id_info_usuario
WHERE inf.nombre_info IN ('tel_celular' ,'correo')
GROUP BY u.num_documento_usuario, u.nombre, u.apellido, u.tipo_documento
tk,