BD Wordpress - 表:wp_term_relationships
object_id | term_taxonomy_id| term_order 1 | 23 | 0 2 | 22 | 0 3 | 23 | 0 4 | 22 | 0 5 | 23 | 0 6 | 21 | 0
我需要计算每个“类别”中有多少“产品”,并在“term_order”列中插入
例如:
object_id | term_taxonomy_id| term_order 1 | 23 | 3 2 | 22 | 2 3 | 23 | 3 4 | 22 | 2 5 | 23 | 3 6 | 21 | 1
我做了这样的事情,但它没有更新字段“term_order”:
UPDATE `letras`.`wp_term_relationships`
SET `term_order` = '2'
WHERE `wp_term_relationships`.`object_id` = '5' ;
SELECT object_id as id_objeto,
COUNT( `object_id` ) quantidade
FROM wp_term_relationships
WHERE `object_id` = `object_id`
GROUP BY `term_taxonomy_id`