gpt4 book ai didi

php - 奇怪的 MYSQL 错误

转载 作者:行者123 更新时间:2023-11-30 23:36:41 25 4
gpt4 key购买 nike

我在文件中的查询在 php 文件中看起来像这样:

SELECT
p.products_id as v_products_id,
p.products_model as v_products_model,
p.products_image as v_products_image,
p.products_price as v_products_price,
p.products_sku as v_products_sku,
p.products_upc as v_products_upc,
p.products_weight as v_products_weight,
p.products_date_added as v_date_added,
p.products_date_available as v_date_avail,
p.products_tax_class_id as v_tax_class_id,
p.products_quantity as v_products_quantity,
p.manufacturers_id as v_manufacturers_id,
subc.categories_id as v_categories_id
FROM
zen_products as p,
zen_categories as subc,
zen_products_to_categories as ptoc
WHERE
p.products_id = ptoc.products_id AND
p.products_model = 'M150XN05' AND
ptoc.categories_id = subc.categories_id

我收到一个返回错误:MySQL 错误 1054:“字段列表”中的未知列“p.produc1925ts_tax_class_id”执行时:

SELECT
p.products_id as v_products_id,
p.products_model as v_products_model,
p.products_image as v_products_image,
p.products_price as v_products_price,
p.products_sku as v_products_sku,
p.products_upc as v_products_upc,
p.products_weight as v_products_weight,
p.products_date_added as v_date_added,
p.products_date_available as v_date_avail,
-- extra 1925 here
p.produc1925ts_tax_class_id as v_tax_class_id,
p.products_quantity as v_products_quantity,
p.manufacturers_id as v_manufacturers_id,
subc.categories_id as v_categories_id
FROM
zen_products as p,
zen_categories as subc,
zen_products_to_categories as ptoc
WHERE
p.products_id = ptoc.products_id AND
p.products_model = 'M150XN05' AND
ptoc.categories_id = subc.categories_id

这是怎么回事,额外的“1925”是如何被放置到选择的中间的?我不知所措,我已经尝试了所有我能想到的可能导致此问题的方法。

完整代码在这里http://pastebin.com/embed_iframe.php?i=Q2RHT00W

最佳答案

MySQL 不会像您期望的那样解析隐式连接。

(引用已删除,因为它是错误的段落,但这是我以前遇到过的已知错误!)

为避免混淆,我建议改用显式连接:

zen_products as p,
zen_categories as subc,
zen_products_to_categories as ptoc
WHERE
p.products_id = ptoc.products_id AND
p.products_model = 'M150XN05' AND
ptoc.categories_id = subc.categories_id

成为

zen_products as p
JOIN zen_products_to_categories as ptoc
ON p.products_id = ptoc.products_id
JOIN zen_categories as subc
ON ptoc.categories_id = subc.categories_id
WHERE p.products_model = 'M150XN05'

关于php - 奇怪的 MYSQL 错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6785200/

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