Comments - User-Defined Variables

9 years, 9 months ago Dongjae Shin
This comment has the status of 'removed' and can only be seen by you.

thanks you very much! i have one more question.

SELECT A.*

,IF(@PREV_JOB=JOB ,@ROWNUMBER:=@ROWNUMBER+1 ,@ROWNUMBER:=1+LEAST(0,@PREV_JOB:=JOB)) AS ROWNUMBER

FROM (SELECT EMP.* --here is inline view

FROM EMP

,(SELECT @ROWNUMBER:=0, @PREV_JOB:='') X

ORDER BY JOB, SAL) A;

As far as I know, mariaDB's inliview ordering is not working.

so i input the sentence ",(SELECT @ROWNUMBER:=0, @PREV_JOB:='') X".

then inline view was ordered, and result was fine.

with out this sentence, sort is not occur in execution plan.

is this ordering is legal? guaranteed? or not guaranteed?

i'm sorry for my poor English. thanks you.

 
Content reproduced on this site is the property of its respective owners, and this content is not reviewed in advance by MariaDB. The views, information and opinions expressed by this content do not necessarily represent those of MariaDB or any other party.