--- id: sql-exists title: "SQL Exists" category: "Database" status: "draft" verification_status: "conceptual" canonical_id: "" aliases: ["SQL EXISTS Operator", "EXISTS operator", "SQL 쑴재 확인"] duplicate_of: "" source_trust_level: "B" confidence_score: 0.9 created_at: 2026-07-04 updated_at: 2026-07-04 review_reason: "" merge_history: [] tags: ["sql", "database", "w3schools", "exists", "subquery"] raw_sources: ["https://www.w3schools.com/sql/sql_exists.asp"] applied_in: [] github_commit: "" --- # [[SQL Exists]] ## 🎯 ν•œ 쀄 톡찰 (One-line insight) EXISTS tests whether a correlated subquery returns any row at all, evaluating to TRUE the moment one match is found β€” a boolean existence check rather than a value comparison. [S1] ## 🧠 핡심 κ°œλ… (Core concepts) - **EXISTS operator** β€” used in a WHERE clause to check whether a subquery returns any rows; TRUE if at least one row, FALSE otherwise. [S1] - **Syntax** β€” `SELECT column_name(s) FROM table_name WHERE EXISTS (subquery);`. [S1] - **Correlated subquery** β€” the subquery typically references the outer query's table (e.g. `Products.SupplierID = Suppliers.supplierID`) to test existence per outer row. [S1] ## πŸ“– μ„ΈλΆ€ λ‚΄μš© (Details) - Suppliers with at least one product priced under 10: [S1] ```sql SELECT SupplierName FROM Suppliers WHERE EXISTS ( SELECT ProductName FROM Products WHERE Products.SupplierID = Suppliers.supplierID AND Price < 10 ); ``` - Same pattern, different threshold (Price = 22), illustrating that EXISTS only cares about row presence, not the queried column's actual values. [S1] ## βš–οΈ λͺ¨μˆœ 및 μ—…λ°μ΄νŠΈ (Contradictions & updates) μ†ŒμŠ€μ—μ„œ λͺ¨μˆœλ˜λŠ” μ •λ³΄λŠ” λ°œκ²¬λ˜μ§€ μ•ŠμŒ. ## πŸ› οΈ 적용 사둀 (Applied in summary) ν˜„μž¬ 발견된 μ‹€μ œ 적용 사둀가 μ—†μŠ΅λ‹ˆλ‹€ β€” IN (SELECT ...)κ³Ό μœ μ‚¬ν•œ λͺ©μ (μ„œλΈŒμΏΌλ¦¬ 기반 필터링)μ΄μ§€λ§Œ, EXISTSλŠ” 값이 μ•„λ‹Œ ν–‰μ˜ 쑴재 μ—¬λΆ€λ§Œ ν™•μΈν•œλ‹€λŠ” 차이가 μžˆλ‹€. [S1] ## πŸ’» μ½”λ“œ νŒ¨ν„΄ (Code patterns) Correlated EXISTS subquery (SQL): ```sql SELECT SupplierName FROM Suppliers WHERE EXISTS ( SELECT ProductName FROM Products WHERE Products.SupplierID = Suppliers.supplierID AND Price < 10 ); ``` ## βœ… 검증 μƒνƒœ 및 신뒰도 - **μƒνƒœ:** draft - **검증 단계:** conceptual - **좜처 신뒰도:** B (W3Schools β€” widely used educational reference, not a primary standards body) - **μ‹ λ’° 점수:** 0.90 - **쀑볡 검사 κ²°κ³Ό:** μ‹ κ·œ 생성 (New discovery) ## πŸ”— 지식 κ·Έλž˜ν”„ (Knowledge Graph) - **μƒμœ„/루트:** [[SQL Tutorial]] - **κ΄€λ ¨ κ°œλ…:** [[SQL In]], [[SQL Any]], [[SQL All]] - **μ°Έμ‘° λ§₯락:** μ„œλΈŒμΏΌλ¦¬ 결과의 "쑴재 μ—¬λΆ€"만 ν™•μΈν•˜λ©΄ λ˜λŠ” 필터링에 μ‚¬μš© β€” κ°’ 비ꡐ가 ν•„μš”ν•˜λ©΄ IN/ANY/ALL을 λŒ€μ‹  κ³ λ €. ## πŸ“š 좜처 (Sources) - [S1] W3Schools β€” SQL EXISTS Operator β€” https://www.w3schools.com/sql/sql_exists.asp ## πŸ“ λ³€κ²½ 이λ ₯ (Change history) - 2026-07-04: Initial draft synthesized from the W3Schools "SQL EXISTS Operator" page (Astra wiki-curation, P-Reinforce v3.1 format).