반응형
여기 내 질문이 있습니다. 두 데이터베이스의 두 테이블에서 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
참조 페이지 https://stackoverflow.com/questions/4242990
반응형
'MySql' 카테고리의 다른 글
MySQL # 1273 – 알 수없는 데이터 정렬 :‘utf8mb4_unicode_520_ci’ (0) | 2020.10.29 |
---|---|
MySQL 테이블을 Oracle DB로 내보내기 (0) | 2020.10.29 |
MySQL 명령 줄을 사용하여 SQL 쿼리를 TXT로 내보내는 방법 (0) | 2020.10.28 |
MySQL Laravel 5.4에서 외래 키 bigInteger를 bigIncrements로 설정 (0) | 2020.10.28 |
MySQL UPDATE에 타임 스탬프를 자동으로 삽입하도록 필드를 설정 하시겠습니까? (0) | 2020.10.28 |
댓글