[SQL] Column: '컬럼명' in where clause is ambiguous 에러

Joy H·2024년 6월 25일

[Error] : Column: '컬럼명' in where clause is ambiguous

: 서로 다른 테이블을 조인했을때 같은 컬럼이 있으면 생기는 에러

	<select id="CmsMenuMng.selectBoardMngDataList" resultType="egovMap" parameterType="vo">
	/* CmsMenuMng.selectBoardMngDataList */
		SELECT
       		T1.board_code,
       		CONCAT('[', T2.site_txt, '] ', T1.title) AS title
	    FROM
	        cms_board T1
	    JOIN
	        cms_site_code T2
	    ON
	        T1.site_code = T2.site_code
		<where>
			<if test='siteCode != "home"'>
			AND			site_code				= #{siteCode}
			</if>
		</where>
		ORDER BY reg_date DESC
	</select>

=> 여기서 join 후에 where절에 site_code 값이 어떤 테이블로 부터 온건지 명시가 안되어 나온 오류
=> 이부분을 AND T1.site_code = #{siteCode} 로 바꾸니 해결

0개의 댓글