SQL 문에서 조건넣을 수 있을까여?
본문
SELECT bo_table, bo_subject, bo_count_write
FROM g5_board
WHERE gr_id='business'
ORDER BY bo_subject ASC"
g5_board에 'no_category'테이블을 포함해서
5개의 행이 존재합니다.
이때 bo_table 의 'no_category ' 테이블의 데이터가 존재하지 않는다면,
이 테이블은 가져오지 않도록 하고 싶은데 방법있을까여?
도움부탁드리겠습니다!
답변 3
SELECT a.bo_table, a.bo_subject, a.bo_count_write
FROM g5_board a
left join no_category b on b.키값 = a.키값
WHERE a.gr_id='business' and b.키값 is not null
ORDER BY a.bo_subject ASC
SELECT bo_table, bo_subject, bo_count_write
FROM g5_board
WHERE gr_id='business'
and no_category is not null
ORDER BY bo_subject ASC
no_category 테이블의 스키마를 보여 주시는 게 아마 좀 더 정확한 답이 나오지 않을까 싶네요.
답변을 작성하시기 전에 로그인 해주세요.