这是我的更新查询:
UPDATE products
SET products_status = 0
WHERE (`products`.`products_id` = `products_to_categories`.`products_id`
and `products_to_categories`.`categories_id` = 114)
我得到的错误是:
1054 - 'where子句'中的未知栏'products_to_categories.products_id'
但是当我去table_to_categories表时,有一个product_id列。
我做错了什么?
答案 0 :(得分:1)
您需要的查询可能就是这个:
UPDATE products
SET products_status = 0
WHERE products_id IN
(SELECT products_id
FROM products_to_categories
WHERE categories_id = 114)
答案 1 :(得分:0)
得到了它:
UPDATE products
SET products_status = 0
WHERE (SELECT products_id FROM products_to_categories
WHERE(
`products`.`products_id` = `products_to_categories`.`products_id` and `products_to_categories`.`categories_id` = 114))