ArmArPa
Zeta
Verificado
Verificación en dos pasos activada
Verificado por Binance
I've been reading how to solve this issue, but since i lack the knowledge to either build this query correctly or even searching for the correct answer i'll have to ask here and hope you can help me out.
Assuming i have a table named VENDORS like this:
How do i build a query so i get this
I was thinking something like this:
But of course this is not working, not sure how to get what i want, it seems easy, but i'm totally lost.
Assuming i have a table named VENDORS like this:
Insertar CODE, HTML o PHP:
ID|name |phone |phone_type
1| Andy |305332 |office
1| Andy |999999 |fax
1| Andy |555555 |cellphone
2| Jack |222222 |office
2| Jack |444444 |fax
3| Peter |234234 |office
3| Peter |434345 |cellphone
How do i build a query so i get this
Insertar CODE, HTML o PHP:
ID|name |phone |fax |cellphone
1| Andy |305332 |999999 |555555
2| Jack |222222 |444444 |NULL
3| Peter |234234 |NULL |434345
I was thinking something like this:
Insertar CODE, HTML o PHP:
SELECT
id,
name,
CASE
WHEN phone_type = 'office'
THEN phone END AS phone
WHEN phone_type = 'fax'
THEN phone END AS fax,
WHEN phone_type = 'cellphone'
THEN phone END AS cellphone
FROM `VENDORS`
GROUP BY id

