Php und MySQL GROUP_CONCAT mit separator Komma und suchen, wo concat durch Komma

Ist es möglich auszuwählen, Group_concat mit Trennzeichen Komma
und wo suchen concat durch Komma
Hier Mein Beispiel von mysql :

products_attributes_id  |products_id|   options_id|     options_values_id 
39                  |   31      |       3     |         3   
35                  |   30      |       2     |         2   
38                  |   30      |       1     |         1   
40                  |   31      |       2     |         2   
41                  |   30      |       1     |         4   
42                  |   30      |       1     |         5   
43                  |   31      |       1     |         4 

Möchte ich GROUP_CONCAT options_values_id

SELECT * , GROUP_CONCAT(options_values_id SEPARATOR ',') AUS products_attributes GRUPPE von products_id

products_attributes_id  |   products_id |   options_id  |   options_values_id   |   options_values_id
35                  |   30          |   2           |   2                   |   2,1,4,5
39                  |   31          |   3           |   3                   |   3,2,4

Nun mein problem ist, Wie finde ich die product_id suchen ( option_values_id mit Komma) wenn mein Wert ist 1,2 oder 2,4 dann bekomme ich nur product_id=30.
Aber wenn ich den Wert 1,3, werde ich nichts bekommen. Da product_id 30 nicht option_values_id 3
und product_id 31 nicht option_values_id 1.

Ich versuche diesen code, aber ich kann nicht die product_id

    SELECT * , GROUP_CONCAT( options_values_id
SEPARATOR ',' )
FROM `products_attributes` WHERE CONCAT(',',options_values_id,',') LIKE '%,1,2,%'
GROUP BY products_id
Vielleicht gibt es eine Möglichkeit dies zu tun ohne mit GROUP_CONCAT? Können Sie uns etwas mehr hintergrund-info?

InformationsquelleAutor Jows | 2013-06-06

Schreibe einen Kommentar