我试图使此查询包括所有product_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
信息说明
parent_id
排序
可见
无索引
language_id


表格:properties_to_information


properties_to_information_id
option_id
information_id

最佳答案

您是否尝试过将INNER JOIN更改为LEFT JOIN? INNER JOIN可能导致查询忽略您要查找的结果集行。

09-20 21:45