You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I've run into a interesting puzzle trying to emulate the row_number function.
With raw SQL, I found how to do it in two ways:
select row_number as seqItem
from
(select
`i`.`id`,
@curRow := @curRow + 1 AS row_number
from
`orderitem` as `i`,
(select @curRow := 0) as `r`
where
`i`.`idCompany` = '123'
and `i`.`idOrder` = '456'
) sub
where sub.id = '789';
or
select row_number as seqItem
from
(select
`i`.`id`,
@curRow := @curRow + 1 AS row_number
from
`orderitem` as `i`
inner join
(select @curRow := 0) as `r`
where
`i`.`idCompany` = '123'
and `i`.`idOrder` = '456'
) sub
where sub.id = '789';
select
`row_number` as `seqItem`
from
(
select
`i`.`id`,
@curRow := @curRow + 1 AS row_number
from
`orderitem` as `i`,
`(select @curRow := 0)` as `r`
where
`i`.`idCompany` = '123'
and `i`.`idOrder` = 456) as `sub`
where
`sub`.`id` = 789;
and it resulted in a error because of the backticks in
`(select @curRow := 0)`
Is this not supported, or I'm just missing something?
Best regards!
The text was updated successfully, but these errors were encountered:
Hello there, how is it going?
I've run into a interesting puzzle trying to emulate the row_number function.
With raw SQL, I found how to do it in two ways:
or
I've tried doing the following
which resulted in the query string
and it resulted in a error because of the backticks in
Is this not supported, or I'm just missing something?
Best regards!
The text was updated successfully, but these errors were encountered: