如何在 mariadb 10.1 中替换“with”语句
How to substitute “with” statement in mariadb 10.1
我在 MariaDB 10.1 中使用第三方软件如何替换 sql "with" 语句(不适用于 MariaDB 10.1)?
我想做这样的事情:
WITH mCte
AS (
SELECT
@row_num: = @row_num + 1 AS Cpt
,field1
FROM (
SELECT @row_num: = 0 AS row_num
,myField AS field1
FROM myTable
) AS T
)
SELECT *
FROM mCte
WHERE Cpt BETWEEN 1 AND 5
谢谢
我建议:
select @row_num := @row_num + 1 AS Cpt, field1
from myTable t cross join
(select @row_num := 0 as row_num) params
limit 5;
通常,我希望查询中有 order by
,但您的代码没有。
我在 MariaDB 10.1 中使用第三方软件如何替换 sql "with" 语句(不适用于 MariaDB 10.1)?
我想做这样的事情:
WITH mCte
AS (
SELECT
@row_num: = @row_num + 1 AS Cpt
,field1
FROM (
SELECT @row_num: = 0 AS row_num
,myField AS field1
FROM myTable
) AS T
)
SELECT *
FROM mCte
WHERE Cpt BETWEEN 1 AND 5
谢谢
我建议:
select @row_num := @row_num + 1 AS Cpt, field1
from myTable t cross join
(select @row_num := 0 as row_num) params
limit 5;
通常,我希望查询中有 order by
,但您的代码没有。