티스토리 뷰
원래 되는 쿼리
SET @rownum := 0;
SELECT e.product_id,
e.id AS episode_id,
@rownum := @rownum +1 AS episode_no,
e.episode_name,
e.star_score,
e.create_date
FROM episode_info e
INNER JOIN product p
ON p.id = e.product_id
WHERE e.product_id = :productId
ORDER BY episode_no DESC
BUT jdbcTemplate은 .query에 한문장이라 오류남
수정
SELECT e.product_id,
e.id AS episode_id,
@rownum := @rownum +1 AS episode_no,
e.episode_name,
e.star_score,
e.create_date
FROM episode_info e
INNER JOIN product p
ON p.id = e.product_id,
(SELECT @rownum := 0) r
WHERE e.product_id = :productId
ORDER BY episode_no DESC
'JAVA > Spring' 카테고리의 다른 글
ApplicationConfig @ComponentScan 범위 오류 (0) | 2019.12.22 |
---|---|
[Spring] Service / Transaction (0) | 2019.10.14 |
[Spring] RowMapper (0) | 2019.10.12 |
[Spring] Connection Pool / Spring JDBC (0) | 2019.10.10 |
[Spring] Controller(Handler) (0) | 2019.10.09 |