我没有收到的部分查询;这些内部连接在做什么?
我有一个包含所有数据的表speeldatum,在我的项目中。下面的查询正在改变rownum列的值,我怎么不明白。在查询中没有内部连接,rownum 列的值为零,我对查询中的 mysql 用户定义的变量没有正确理解。
样本输出(不要考虑 ROWNUM 值的顺序)
....,rownum 0 ....
...,rownum 1,...
...,rownum 2,...
from speeldatums as t
inner join (select @rownum:=0) as r
inner join (select @prev:="") as r2
inner join (select @prevdatum:="") as r3**
完整查询:
'create temporary table rr_prepare ( rownum INT NOT NULL, datum_unix
INT(11) NULL, categorie VARCHAR(20) NOT NULL, entry_id INT NOT NULL,
INDEX(rownum), INDEX(datum_unix), INDEX(categorie), INDEX(entry_id) )
ENGINE=MyISAM
select t.*, @rownum:=if(@prev=t.categorie and
@prevdatum=t.datum,@rownum+1,0) as rownum, @prev:=t.categorie as
prevcategorie, @prevdatum:=t.datum as prevdatum
from speeldatums as t inner join (select @rownum:=0) as r
inner join (select @prev:="") as r2
inner join (select @prevdatum:="") as r3 ';