반응형
MySQL: 둘 이상 발생한 행 선택
제 질문은 이렇습니다.두 데이터베이스에 걸쳐 두 개의 테이블에서 ID 목록을 선택합니다.쿼리가 정상적으로 작동합니다.
select en.id, fp.blogid
from french.blog_pics fp, french.blog_news fn, english.blog_news en
where fp.blogid = fn.id
and en.title_fr = fn.title
and fp.title != ''
행을 표시할 때만 다음과 같이 표시합니다.en.id
두 번 이상 발생합니다.
예를 들어, 이것이 현재의 쿼리 결과였다면
en.id fp.blogid
---------------
10 12
12 8
17 9
12 8
대신 이것을 보여주기 위해 쿼리만 하려고 합니다.
en.id fp.blogid occurrences
-----------------------------
12 8 2
select en.id, fp.blogid, count(*) as occurrences
from french.blog_pics fp, french.blog_news fn, english.blog_news en
where fp.blogid = fn.id
and en.title_fr = fn.title
and fp.title != ''
group by en.id
having count(*) > 1
언급URL : https://stackoverflow.com/questions/4242990/mysql-select-rows-with-more-than-one-occurrence
반응형
'programing' 카테고리의 다른 글
C에서 : 연산자의 사용 (0) | 2023.10.29 |
---|---|
우커머스에서 날짜별로 사용자 주문을 받는 방법은? (0) | 2023.10.29 |
WordPress: meta_query가 있는 게시물 제외 - 모든 게시물에 meta_field가 있는 것은 아닙니다. (0) | 2023.10.29 |
MySQL 타임스탬프에 NULL 삽입 (0) | 2023.10.24 |
iframe이 로드되었는지 여부를 확인하려면 어떻게 해야 합니까? (0) | 2023.10.24 |