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

;

 

출처: <http://www.rcy.co.kr/xeb/index.php?mid=study&comment_srl=2555&listStyle=list&sort_index=blamed_count&order_type=desc&page=6&document_srl=5991>