아래와 같은 쿼리입니다.
SELECT visual_idx, visual_config_idx, title, sub_title, content, status, seq_no, anchor, file_path, file_name, deleted, s_date, e_date, register_date, update_date FROM visual where visual_config_idx = '1' and seq_no='2' order by update_date DESC LIMIT 1;
제가 가져오고 싶은것은
and seq_no='1' 일때의 update_date DESC 로 맨위에 거 한건
and seq_no='2' 일때의 update_date DESC 로 맨위에 거 한건
총 두건만 동시에 가져오고 싶은데요........
그래서 아래와 같이 해보았는데 제가 원하는 결과는 아니더군요
and seq_no='2' or seq_no='1' order by update_date DESC LIMIT 2
도움 부탁드립니다.
SELECT * FROM ( SELECT visual_idx, visual_config_idx, title, sub_title, content, status, seq_no, anchor, file_path, file_name, deleted, s_date, e_date, register_date, update_date, ROW_NUMBER() OVER(PARTITION BY seq_no ORDER BY update_date DESC ) rn FROM visual WHERE visual_config_idx = '1' AND seq_no IN ( '1' , '2' ) ) A WHERE rn = 1