我有 user_contents 表。这是DDL
CREATE TABLE `user_contents` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`user_id` int(11) NOT NULL,
`content_type` int(11) NOT NULL,
`order_id` int(11) DEFAULT '0',
PRIMARY KEY (`id`),
KEY `user_id` (`user_id`),
CONSTRAINT `user_contents_ibfk_1` FOREIGN KEY (`user_id`) REFERENCES `user` (`id`)
)
order_id 是新添加的列。我需要根据 content_type 和 user_id 的值更新 order_id 的值。content_type 可以是 0 或 1。
基于 content_type 和 user_id 我必须更新 order_id 如上面的结果所示。对于相同的 user_id 和 content_type order_id 需要从 0 开始递增。
有人可以帮我更新查询吗
我正在使用版本5.7.23-0ubuntu0.16.04.1的mysql db
编辑: - - 现在要求略有改变。user_id 的 data_type int 改为 varchar 保存值,如 DAL001、HAL001 等

