Error Note

[SQL Error] SQLSyntaxErrorException

Juun 2022. 5. 23. 11:50
반응형

MyBatis 게시판을 만들고 TDD로 테스트하던 중 생긴 에러이다

 

Caused by: java.sql.SQLSyntaxErrorException: You have an error in your SQL syntax; 

check the manual that corresponds to your MySQL server version for the right syntax to use near 'null, null' at line 6

The error occurred while setting parameters
### SQL: SELECT count(*)         FROM board         WHERE true         AND title Like concat('%', ?, '%')         

ORDER BY reg_date DESC, bno DESC             LIMIT ?, ?

 

SQL 문에서 문법이 잘못된 에러이다

 

<select id="searchResultCnt" parameterType="SearchCondition" resultType="int">
        SELECT count(*)
        FROM board
        WHERE true
        AND title LIKE concat('%', #{keyword}, '%')
        ORDER BY reg_date DESC, bno DESC
        LIMIT #{offset}, #{pageSize}
    </select>

 SQL Grammar에서 count와 LIMIT은 order by가 필요없는데 넣어줘서 생긴 에러

<select id="searchResultCnt" parameterType="SearchCondition" resultType="int">
        SELECT count(*)
        FROM board
        WHERE true
        AND title LIKE concat('%', #{keyword}, '%')
    </select>

아래 두줄을 삭제해주니 해결되었다

 

반응형