gpt4 book ai didi

mysql - 我的 SQL 查询给出 'bisns.attribute_id' 中的未知列 'on clause'

转载 作者:行者123 更新时间:2023-11-29 23:41:37 24 4
gpt4 key购买 nike

此代码及其关联的数据库表正在另一个站点上使用并且运行良好。但是,当我在另一个网站上使用它时,出现错误。我检查了表,列 attribute_id 确实存在。

SELECT bisns.product_id, pd.products_name, COUNT(*) AS num_subscribers, p.products_type,GROUP_CONCAT(DISTINCT CONCAT_WS(':', IFNULL(bisns.attribute_id, 'attribute_id'), pov.products_options_values_name, IFNULL(pwas.quantity, 'quantity'), IFNULL(bisns.customer_id, 'customer_id'), bisns.name, bisns.email_address)) as attributes, COUNT(DISTINCT bisns.product_id) as product_count_distinct, COUNT(DISTINCT bisns.attribute_id) as attribute_count_distinct, COUNT(bisns.attribute_id) as attribute_count,p.products_quantity AS current_stock, cd.categories_name
FROM
" . TABLE_BACK_IN_STOCK_NOTIFICATION_SUBSCRIPTIONS . " bisns
LEFT JOIN
" . TABLE_PRODUCTS_DESCRIPTION . " pd
ON
(pd.products_id = bisns.product_id
AND
pd.language_id = '" . $_SESSION['languages_id'] . "')
LEFT JOIN
" . TABLE_PRODUCTS . " p
ON
p.products_id = pd.products_id
LEFT JOIN
" . TABLE_CATEGORIES_DESCRIPTION . " cd
ON
(p.master_categories_id = cd.categories_id
AND
cd.language_id = '" . $_SESSION['languages_id'] . "')
LEFT JOIN " . TABLE_PRODUCTS_ATTRIBUTES . " pa
ON pa.products_attributes_id = bisns.attribute_id
LEFT JOIN " . TABLE_PRODUCTS_OPTIONS . " po
ON pa.options_id = po.products_options_id
LEFT JOIN " . TABLE_PRODUCTS_OPTIONS_VALUES . " pov
ON pa.options_values_id = pov.products_options_values_id
LEFT JOIN " . TABLE_PRODUCTS_WITH_ATTRIBUTES_STOCK . " pwas
ON pa.products_attributes_id = pwas.stock_attributes
WHERE
1 = 1
GROUP BY
bisns.product_id"

任何人都可以想出这个查询会抛出错误的原因以及我如何解决它,因为它让我失败了。

最佳答案

首先要做的是检查小写和大写是否存在差异。根据设置,MySQL 将或不会检查大小写是否完全匹配。

第二件事是在替换完成后打印上述 sql 字符串的最终结果,以确保一切正常。

最后,您可以尝试直接在 MySQL Workbench 中运行最终查询,看看可能出现什么错误。

关于mysql - 我的 SQL 查询给出 'bisns.attribute_id' 中的未知列 'on clause',我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26131152/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com