0

这是我的更新查询:

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'

但是当我转到表 products_to_categories 时,有一列 products_id。

我究竟做错了什么?

4

2 回答 2

1

您需要的查询可能是这个:

UPDATE products
SET products_status = 0
WHERE products_id IN 
(SELECT products_id 
 FROM products_to_categories
 WHERE categories_id = 114)
于 2012-11-27T16:46:10.133 回答
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))
于 2012-11-27T16:37:26.917 回答