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
261
April 20, 2020 11:45AM
Re: Union de consultas
104
April 20, 2020 01:35PM
93
April 26, 2020 06:45AM
105
April 27, 2020 01:26PM
95
April 27, 2020 02:05PM


Sorry, only registered users may post in this forum.

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.