MySQL Forums
Forum List  »  German

Re: left join mit case?
Posted by: Thomas Wiedmann
Date: October 13, 2010 01:09PM

So, jetzt habe ich es glaube ich verstanden. Existiert die Variante X nicht, wird der Text aus Variante 0 verwendet. Probiert mal dies..

SELECT p.id_produkt, 
       COALESCE(MAX(tx.produkt_bezeichnung ),MAX(t0.produkt_bezeichnung )) AS produkt_bezeichnung,
       COALESCE(MAX(tx.produkt_beschreibung),MAX(t0.produkt_beschreibung )) AS produkt_beschreibung
  FROM PRODUKTTAB p
  LEFT JOIN PRODUKTTEXTTAB tx
    ON tx.produkt_id = p.id_produkt 
   AND tx.variante_id = 2 -- $var_variante_id
   AND tx.sprach_id = 1 -- $var_irgendeinesprach_id    
  LEFT JOIN PRODUKTTEXTTAB t0
    ON t0.produkt_id = p.id_produkt 
   AND t0.variante_id = 0  -- Immer Variante 0
   AND t0.sprach_id = 1 -- $var_irgendeinesprach_id 
GROUP BY p.id_produkt
ORDER BY p.id_produkt;

Grüße
Thomas

Options: ReplyQuote


Subject
Views
Written By
Posted
2248
October 13, 2010 10:55AM
2165
October 13, 2010 12:00PM
1409
October 13, 2010 12:37PM
1362
October 13, 2010 12:59PM
Re: left join mit case?
1293
October 13, 2010 01:09PM
1106
October 13, 2010 01:22PM
1142
October 13, 2010 02:51PM
1051
October 14, 2010 03:49AM


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.