mysql update 問題 急
表 vote_orders 是做排名用的
CREATE TABLE IF NOT EXISTS `vote_orders` (
`oid` int(11) NOT NULL auto_increment,
`aid` int(11) NOT NULL,
`orders` int(11) NOT NULL default '0',
`counts` int(11) NOT NULL default '0',
PRIMARY KEY (`oid`)
) ENGINE=MyISAM DEFAULT CHARSET=gb2312 COLLATE=gb2312_bin AUTO_INCREMENT=4 ;
我想根據counts的大小進行排名 名次記錄在orders 字段
但是以下語句會報錯
UPDATE `vote_orders`
SET `orders` = ( SELECT count( * ) +1
FROM `vote_orders` b
WHERE b.counts > vote_orders
.counts )
請各位大俠幫忙修改sql語句
拜謝
|