如何在MySQL中使用“WITH”子句?我正在将我所有的SQLServer查询转换为MySQL,并将我的查询转换为WITH他们都失败了。下面是一个例子:WITH t1 AS(
SELECT article.*, userinfo.*, category.*
FROM question INNER JOIN userinfo ON userinfo.user_userid = article.article_ownerid
INNER JOIN category ON article.article_categoryid = category.catid
WHERE article.article_isdeleted = 0)SELECT t1.*FROM t1ORDER BY t1.article_date DESCLIMIT 1, 3
3 回答
精慕HU
TA贡献1845条经验 获得超8个赞
WITH RECURSIVE my_cte AS
(
SELECT 1 AS n
UNION ALL
SELECT 1+n FROM my_cte WHERE n<10
)
SELECT * FROM my_cte;
+------+
| n |
+------+
| 1 |
| 2 |
| 3 |
| 4 |
| 5 |
| 6 |
| 7 |
| 8 |
| 9 |
| 10 |
+------+
10 rows in set (0,00 sec)
添加回答
举报
0/150
提交
取消