0
在工作臺上打開一個新的會話並嘗試運行此查詢此查詢在第一次執行時返回計數'15' ,第二次執行時返回'4'爲什麼它如此..Mysql查詢給出不同的計數第一次和第二次執行
select count(id)
from (
select *,@num := if(@company_id = company_id, @num + 1, 1) as row_number,@company_id := company_id as dummy
from salebuild_ctl.company_contact
where id in (12352,59898,59899,59900,59901,59902,59903,59904,14047,15196,15197,41402,41403,41404,41405)
order by company_id, date_created asc
) as x
where x.row_number <= 2;
什麼IST的'選擇@num結果之前正常運行;您查詢的每個調用之前'? – Lars 2013-03-01 06:21:36