ich Ich möchte auch die c.category, wenn p.ptype ist nicht in dem Satz von c.ptypeMit DISTINCT mit FIND_IN_SET
DISTINCT (p.ptype) zur gleichen Zeit wählendenDatenbanktabelle : p
id ptype
1 Shirts
2 Cups
3 Shirts
4 Mugs
Database Tabelle: c
id category ptype
1 Test Pants, Shirts, TShirts
2 Test1 Cups, Mats, Rugs
Der SQL-Befehl ist, habe ich versucht, wie folgt
SELECT DISTINCT(p.ptype), IF(FIND_IN_SET(p.ptype, c.ptype), c.category,'') as category
FROM p, c
Dies gibt p.type aus, die zweimal gesetzt sind. Einmal mit leerem c.category-Feld und einmal mit gefülltem c.category.
jedoch die gewünschte Ausgabe ist wie folgt
ptype category
Shirts Test
Cups Test1
Mugs