mysql 썸네일형 리스트형 [MySQL][Mybatis]LIKE검색할 때 충분히 할 수 있는(?) 실수 LIKE검색 기능을 만들던 중 쿼리도 잘짠거같고 HTML에서 Action으로 넘긴 값도 Controller에 잘 출력되는데 왜 오류가 나는거지? 했는데...! select 찾는 내용이 있는 컬럼 from table1 where 찾는 내용이 있는 컬럼 like '%${keyword}%' 어디서 오류가 난거지 했더니!.. mybatis에서 받아온 parameter로 검색할땐 %와 떼어놔 줘야 인식한다는걸 깨달았다..!! 따라서 select 찾는 내용이 있는 컬럼 from table1 where 찾는 내용이 있는 컬럼 like "'%'+${keyword}+'%'" '%${keyword}%' => "'%'+${keyword}+'%'" 로 바꿔주면 오류가 나지 않고 해결 된다! 여기를 바꿔줘도 오류가 난거면.. .. 더보기 [MySql]MySql에서 삼항연산하기 자바에 삼항 연산이 있죠 a=b? c : d MySql에도 있고 Oracle 도 있는데 그 중 MySql에는 여러가지방법이 있습니다. 그 중에서 하나 써놓으려고 합니다. if(조건,true,false) 이러한 형태로 작성 해주셔야 하는데요 예를 하나 들어볼게요 update table1 set value1 = #{value} where value2 = if((select count(*) from table2) > 0, trueVal, falseVal) 이런식으로 서브쿼리를 응요할 수 도 있습니다! 결과가 true false로 나올 수 있게 짠다면 이용방법이 다양해질것 같네요! 더보기 [Mybatis][MySql] insert, update, delete에 selectKey 넣기 select board_no from com_post where post_no = #{postNo} /* post.updateReportCnt */ update com_board set report_cnt = (select sum(post_report_cnt) from com_post where board_no = #{boardNo}) where board_no = #{boardNo} select ifnull(max(rp_no),0)+1 from com_reply /* post.insertReply */ insert into com_reply ( post_no, post_title, rp_no, rp_contents, rp_writer, rp_date )values( #{postNo}, #{postTit.. 더보기 이전 1 다음