我的文件查询在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”放入选择的中间?我不知所措,我已经尝试了所有我能想到的可能导致这种情况的事情。
答案 0 :(得分:0)
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'