채택완료

SQL 문에서 조건넣을 수 있을까여?

2014-08-19 (화) 17:30:56 4,683

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개

채택된 답변
+20 포인트

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 

2014-08-19 (화) 18:53:26

no_category 테이블의 스키마를 보여 주시는 게 아마 좀 더 정확한 답이 나오지 않을까 싶네요.

2014-08-19 (화) 17:56:54

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 

답변을 작성하려면 로그인이 필요합니다.