MSSQL
MSSQL WITH 절을 MySQL 구문으로 변경
돕니
2018. 1. 7. 17:41
MSSQL에서 WITH 을 사용하는 SQL문입니다.
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 t1
ORDER BY t1.article_date DESC limit 1 ,
3
;
이 SQL문을 MySQL용으로 변경하면 다음과 같습니다.
SELECT t1.*
FROM (
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
) t1
ORDER BY t1.article_date DESC limit 1 ,
3
;