MySQL Forums
Forum List  »  Spanish

Re: Union de consultas
Posted by: Peter Brawley
Date: April 20, 2020 01:35PM

No es una unión. Una tabla cruzada o pivote. Consulte "TCrosstabs (Pivot tables)" en https://www.artfulsoftware.com/queries.php

No tengo su DDL pero la consulta se verá así ...

select 
  ac.code, ac.description, c.cod,
  if(c.cod=1,c.description,'') as barcode, -- pivotes ...
  if(c.cod=2,c.description,'') as factory, -- una expresión para  
  if(c.cod=3,c.description,'') as own      -- cada posibilidad
from articles_codes ac 
join article        a on ac.code=a.cod
join codetype       c on ac.codetype=c.cod

Options: ReplyQuote


Subject
Views
Written By
Posted
466
April 20, 2020 11:45AM
Re: Union de consultas
224
April 20, 2020 01:35PM
190
April 26, 2020 06:45AM
205
April 27, 2020 01:26PM
172
April 27, 2020 02:05PM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.