왼쪽 조인 불일치: 행 생략
이 쿼리에서는 #appSteps 테이블과 #appProgress 테이블 간의 LEFT JOIN이 제대로 작동하지 않아 결과에서 예상 행 제외 set.
질문 쿼리:
select p.appId, s.stepId, s.section, p.start from #appSteps s with (nolock) left join #appProgress p on s.stepId = p.stepId where s.section is not null and p.appId = 101
예상 결과:
appId | stepId | section | start |
---|---|---|---|
101 | 1 | Section 1 | 2016-01-03 00:00:00.000 |
101 | 2 | Section 2 | 2016-01-03 00:00:00.000 |
101 | 10 | Section 3 | NULL |
실제 결과:
appId | stepId | section | start |
---|---|---|---|
101 | 1 | Section 1 | 2016-01-03 00:00:00.000 |
101 | 2 | Section 2 | 2016-01-03 00:00:00.000 |
해결 방법:
WHERE 절에 오른쪽 테이블(#appProgress)을 포함하면 잘못된 동작이 발생합니다. 이 조건을 LEFT JOIN의 ON 절로 이동하면 원하는 결과를 얻을 수 있습니다.
Select P.appId, S.stepId, S.section, P.start From #appSteps S With (NoLock) Left Join #appProgress P On S.stepId = P.stepId And P.appId = 101 Where S.section Is Not Null
LEFT JOIN에서는 조인 후에 WHERE 절이 실행됩니다. 즉, 오른쪽부터 행이 WHERE 절 기준을 충족하지 않는 핸드 테이블은 결과 집합에서 제외됩니다. WHERE 절에 오른쪽 테이블을 포함하면 효과적으로 INNER JOIN으로 변환되어 예상 결과가 필터링됩니다.
위 내용은 왼쪽 조인 결과에서 행이 누락되는 이유는 무엇입니까?의 상세 내용입니다. 자세한 내용은 PHP 중국어 웹사이트의 기타 관련 기사를 참조하세요!

mysqloffersvariouscharactersetsforstringdatatypes : 1) latin1forwesterneuropeanlanguages, 2) utf8formultulaultualsupport, 3) UTF8MB4F orextendedUnicodeincludeemojis, 4) UCS2Forfixed-widTheNcoding 및 5) asciiforbasiclatin.ChoingTherightSetensuresDatainTegrity

스트리밍 블로브는 메모리 사용량을 줄이고 성능을 향상시키기 때문에 직접 저장보다 더 좋습니다. 1) 파일을 점차적으로 읽고 처리함으로써 데이터베이스 팽창 및 성능 저하를 피합니다. 2) 스트리밍에는 더 복잡한 코드 로직이 필요하며 I/O 작업 수를 증가시킬 수 있습니다.

mysqlStringTypESmpactStorageAndperformanceAsfollows : 1) charisfixed, adlaysamestoragespace.

mysqlstringtypesincludevarchar, text, char, enum, and set.1) varcharisversatileforvariable-lengthstringsupciedlimit.2) textisidealforlargetextStorage whithoudfinedlength.3) charisfixed, witableforconsistentDatalikecodes.4)

mysqloffersvariousstringdatatatypes : 1) charfixed-lengthstrings, 2) varcharforvariable-lengthtext, 3) binaryandvarbinaryforbinarydata, 4) blobandtextforlargedata 및 5) enumandsetforcontrolledInput.achtolledinput.CheachorciCificusessandperististicatististicatististics

ToadDuserSinMySqleFeffectially, 다음에 따르면, 다음 사항을 따르십시오

toaddanewuser와 함께 complexpermissionsinmysql, followthesesteps : 1) createShereuser'NewUser '@'localhost'Identifiedby'pa ssword ';. 2) grantreadaccesstoalltablesin'mydatabase'withgrantselectonmydatabase.to'newuser'@'localhost';. 3) GrantWriteAccessto '


핫 AI 도구

Undresser.AI Undress
사실적인 누드 사진을 만들기 위한 AI 기반 앱

AI Clothes Remover
사진에서 옷을 제거하는 온라인 AI 도구입니다.

Undress AI Tool
무료로 이미지를 벗다

Clothoff.io
AI 옷 제거제

Video Face Swap
완전히 무료인 AI 얼굴 교환 도구를 사용하여 모든 비디오의 얼굴을 쉽게 바꾸세요!

인기 기사

뜨거운 도구

Eclipse용 SAP NetWeaver 서버 어댑터
Eclipse를 SAP NetWeaver 애플리케이션 서버와 통합합니다.

메모장++7.3.1
사용하기 쉬운 무료 코드 편집기

에디트플러스 중국어 크랙 버전
작은 크기, 구문 강조, 코드 프롬프트 기능을 지원하지 않음

MinGW - Windows용 미니멀리스트 GNU
이 프로젝트는 osdn.net/projects/mingw로 마이그레이션되는 중입니다. 계속해서 그곳에서 우리를 팔로우할 수 있습니다. MinGW: GCC(GNU Compiler Collection)의 기본 Windows 포트로, 기본 Windows 애플리케이션을 구축하기 위한 무료 배포 가능 가져오기 라이브러리 및 헤더 파일로 C99 기능을 지원하는 MSVC 런타임에 대한 확장이 포함되어 있습니다. 모든 MinGW 소프트웨어는 64비트 Windows 플랫폼에서 실행될 수 있습니다.

ZendStudio 13.5.1 맥
강력한 PHP 통합 개발 환경