2010-11-28 12 views
2

これは問題なく動作します。mysql BLOBの問題

SET @postrownum = 0, @postrank = 1, @postprev_val = NULL, @postprev_postnum = NULL; 

SELECT @postrownum := @postrownum + 1 AS row, 
@postrank := IF(@postprev_val!=postcount,@postrownum,@postrank) AS postrank, 
c.user_id, 
@postprev_postnum := IF(@postprev_val!=postcount,@postprev_val-postcount,@postprev_postnum) as morepost, 
@postprev_val := postcount as postcount, 
postcount*5 as postpoint from 

(
select user_id,count(user_id) as postcount from post group by user_id order by postcount desc) as c 

細かい

SET @postrownum = 0, @postrank = 1, @postprev_val = NULL, @postprev_postnum = NULL; 

select id,postrank,morepost,postcount,postpoint from user as a left join 

(SELECT @postrownum := @postrownum + 1 AS row, 
@postrank := IF(@postprev_val!=postcount,@postrownum,@postrank) AS postrank, 
c.user_id, 
@postprev_postnum := IF(@postprev_val!=postcount,@postprev_val-postcount,@postprev_postnum) as morepost, 
@postprev_val := postcount as postcount, 
postcount*5 as postpoint from 

(
select user_id,count(user_id) as postcount from post group by user_id order by postcount desc) as c) as b on a.id=b.user_id 

morepostは奇妙、[BLOB-1B]に戻ります。このdoesntの仕事。助けてもらえますか?

答えて

1

奇妙なことに、これは問題です。

@ postprev_postnum = NULL;

iは

@postprev_postnum = 0に設定します。

2番目のコードで動作します。

なぜあなたは理解できません。