0

選択した言語に関連する行が情報テーブルにない場合でも、すべての products_options_name の結果を含めるようにこのクエリを作成しようとしています。ここでクエリを実行すると、情報テーブルで選択した言語に関連する行を持つ products_propoptions のみが表示されます。

どんな助けでも大歓迎です。前もってありがとう、バス

SELECT PPO.products_options_name, I.information_title, PTL.information_id, 
COUNT(PPA.products_attributes_id) as amount, 
options_id FROM products_propattributes PPA 
INNER JOIN products_propoptions PPO ON PPA.options_id = PPO.products_options_id
LEFT JOIN properties_to_information PTL ON PPA.options_id = PTL.option_id   
LEFT JOIN information I ON PTL.information_id = I.information_id
WHERE PPO.language_id = 6 AND I.language_id = 6 AND PPA.products_id = 121
GROUP BY PPA.options_id ORDER BY PPA.products_options_sort_order

表: products_propoptions

  • products_options_id
  • language_id
  • products_options_name
  • products_options_sort_order

表: products_propattributes

  • products_attributes_id
  • products_id
  • options_id
  • options_values_id
  • options_values_price
  • price_prefix
  • products_options_sort_order

表: 情報

  • information_id
  • information_group_id
  • information_title
  • information_description
  • 親ID
  • sort_order
  • 見える
  • インデックスなし
  • language_id

表: properties_to_information

  • properties_to_information_id
  • option_id
  • information_id
4

2 に答える 2

0

INNER JOIN を LEFT JOIN に変更してみましたか? INNER JOIN が原因で、クエリが探している結果セットの行を省略している可能性があります。

于 2013-06-15T19:15:00.767 に答える