これが混乱を招く可能性があることは承知していますが、これについてはご容赦ください。
ほとんど同じ結果セットを返すわずかな違いがある 2 つの SELECT クエリがあります。
SELECT products_id,options_values_id
FROM products_attributes pa
LEFT JOIN products_options po ON ( pa.options_id = po.products_options_id )
WHERE products_id ='574' and pa.options_id!=6
and pa.options_id!=3
AND products_options_type = 6
GROUP BY products_id,options_values_id
ORDER BY products_id,products_options_sort_order,options_id
2 番目のクエリは次の場所で異なりますproducts_options_type
SELECT products_id,options_values_id
FROM products_attributes pa
LEFT JOIN products_options po ON ( pa.options_id = po.products_options_id )
WHERE products_id ='574' and pa.options_id!=6
and pa.options_id!=3
AND products_options_type = 2
GROUP BY products_id,options_values_id
ORDER BY products_id,products_options_sort_order,options_id
そして、それらによって返される結果は
574|193
574|204
と
574|25
574|3
次のように出力したい
574|193|25
574|204|3
私が試したのは:
SELECT pa.products_id,pa.options_values_id,ord.options_values_id
FROM products_attributes pa
LEFT JOIN products_options po ON ( pa.options_id = po.products_options_id )
LEFT JOIN(SELECT products_id,options_values_id
FROM products_attributes pa
LEFT JOIN products_options po ON ( pa.options_id = po.products_options_id )
WHERE products_id ='574' and pa.options_id!=6
and pa.options_id!=3
AND products_options_type = 2
GROUP BY products_id,options_values_id
ORDER BY products_id,products_options_sort_order,options_id)ord ON pa.products_id=ord.products_id
WHERE paproducts_id ='574' and pa.options_id!=6
and pa.options_id!=3
AND products_options_type = 2
GROUP BY pa.products_id,pa.options_values_id
ORDER BY pa.products_id,products_options_sort_order,options_id
ただし、これは戻ります
574|193|25
574|204|25
私は結合があまり得意ではないので、これを行うことができるかどうか、またどのように行うことができるか考えていますか?