Tengo la siguiente consulta
SELECT users.name as Nombre, users.surname as Apellido, users.email, provinces.name as Provincia, contactInfos.contactType AS tipo, contactInfos.value as Numero
FROM clients
INNER JOIN loans ON loans.client_id = clients.id
INNER JOIN loansTypes ON loansTypes.id = loans.loanType_id
INNER JOIN users ON users.id = clients.user_id
LEFT JOIN locations ON clients.location_id = locations.id
LEFT JOIN provinces ON provinces.id = locations.province_id
LEFT JOIN contactInfos ON contactInfos.id = clients.phone_id OR contactInfos.id = clients.cellPhone_id
WHERE loansTypes.display_name = "Sitio privado"
Donde la tabla que me trae problemas es:
LEFT JOIN contactInfos ON contactInfos.id = clients.phone_id OR contactInfos.id = clients.cellPhone_id
Porque obtengo lo siguente
| nombre | apellido | email | provincia | tipoContacto | numero|
|--------|----------|-------|-----------|--------------|-------|
| A | B |[email protected]| C | TELEFONO | 345 |
|------------------------------------------------------|-------|
| A | B |[email protected]| C | CELULAR | 654 |
----------------------------------------------------------------
donde tipo de contacto es telefono o celular y ami me gustaría tener TODO en un solo registro
Nombre, apellido, email, provincia, celular y telefono