2011-01-01 4 views

答えて

1

あなたが参加し、内側シミュレートし、

set @pos:=0; 
update 
    stories a, 
    (select topic, @pos:[email protected]+1 as new_position 
    from stories 
    where newstype=2 group by topic 
) as b 
set a.position=b.new_position 
where a.topic=b.topic; 
のように、最初のテーブルに更新することができます
0

あなたは、常にメインクエリで)最初のクエリ

`SELECT `topic` FROM `stories` WHERE `newstype`='2' GROUP BY `topic` 

を実行した後、IN(で使用するためのフォーマットにそれを解析してみてください。

ああ、私はPHPを見ていると思っていましたが、全体の質問リストではありません。

関連する問題