--- id: sql-where title: "SQL Where" category: "Database" status: "draft" verification_status: "conceptual" canonical_id: "" aliases: ["SQL WHERE Clause", "WHERE clause", "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", "where", "filter", "operators"] raw_sources: ["https://www.w3schools.com/sql/sql_where.asp"] applied_in: [] github_commit: "" --- # [[SQL Where]] ## 🎯 ν•œ 쀄 톡찰 (One-line insight) The WHERE clause filters records to only those that fulfill a specific condition, and works not just in SELECT but also in UPDATE and DELETE statements. [S1] ## 🧠 핡심 κ°œλ… (Core concepts) - **WHERE clause** β€” extracts only records that satisfy a given condition; usable in `SELECT`, `UPDATE`, `DELETE`. [S1] - **WHERE syntax** β€” `SELECT column1, column2, ... FROM table_name WHERE condition;`. [S1] - **Text vs. numeric fields** β€” text values must be wrapped in single quotes (`'Mexico'`), while numeric fields should NOT be quoted. [S1] - **Comparison operators in WHERE** β€” `=`, `>`, `<`, `>=`, `<=`, `<>` (or `!=` in some SQL dialects), plus `BETWEEN`, `LIKE`, `IN`. [S1] ## 🧩 μΆ”μΆœλœ νŒ¨ν„΄ (Extracted patterns) - **Quote-by-type rule** β€” quote text values, never quote numeric values, when writing WHERE conditions. [S1] - **WHERE is statement-agnostic** β€” the same filtering syntax generalizes across SELECT/UPDATE/DELETE rather than being SELECT-specific. [S1] ## βš–οΈ 비ꡐ 및 선택 κΈ°μ€€ (Comparison & decision criteria) | ν•­λͺ© (Option) | μž₯점 | 단점 | μ–Έμ œ 선택 | |---|---|---|---| | **`=` 단일 κ°’ 비ꡐ** | κ°€μž₯ λ‹¨μˆœν•˜κ³  λͺ…확함 | λ²”μœ„Β·νŒ¨ν„΄ 쑰건 ν‘œν˜„ λΆˆκ°€ | μ •ν™•νžˆ μΌμΉ˜ν•˜λŠ” κ°’ ν•˜λ‚˜λ₯Ό 찾을 λ•Œ | | **`BETWEEN` / `IN` / `LIKE`** | λ²”μœ„Β·λͺ©λ‘Β·νŒ¨ν„΄ 쑰건을 κ°„κ²°ν•˜κ²Œ ν‘œν˜„ | λ‹¨μˆœ 비ꡐ보닀 읽기/μ„±λŠ₯ λΉ„μš©μ΄ 더 λ“€ 수 있음 | λ²”μœ„ ν•„ν„°, 닀쀑 후보값, λΆ€λΆ„ λ¬Έμžμ—΄ 맀칭이 ν•„μš”ν•  λ•Œ | ## πŸ“– μ„ΈλΆ€ λ‚΄μš© (Details) - Select all customers from Mexico: [S1] ```sql SELECT * FROM Customers WHERE Country = 'Mexico'; ``` - Numeric fields are not quoted: [S1] ```sql SELECT * FROM Customers WHERE CustomerID = 1; ``` - Operators other than `=` can filter the search, e.g. greater-than: [S1] ```sql SELECT * FROM Customers WHERE CustomerID > 80; ``` - Operators available in the WHERE clause: `=` (equal), `>` (greater than), `<` (less than), `>=` (greater than or equal), `<=` (less than or equal), `<>` (not equal β€” written `!=` in some SQL versions), `BETWEEN` (range), `LIKE` (pattern search), `IN` (multiple possible values). [S1] ## βš–οΈ λͺ¨μˆœ 및 μ—…λ°μ΄νŠΈ (Contradictions & updates) - **`<>` vs `!=`**: μ†ŒμŠ€ μžμ²΄κ°€ "일뢀 SQL λ²„μ „μ—μ„œλŠ” `<>`κ°€ `!=`둜 쓰일 수 μžˆλ‹€"κ³  λͺ…μ‹œ β€” ν‘œμ€€ ν‘œκΈ°(`<>`)와 방언별 ν‘œκΈ°(`!=`)κ°€ 곡쑴함을 μ•Œλ €μ€Œ. [S1] ## πŸ› οΈ 적용 사둀 (Applied in summary) ν˜„μž¬ 발견된 μ‹€μ œ 적용 사둀가 μ—†μŠ΅λ‹ˆλ‹€ β€” WHERE μ ˆμ€ 이후 AND/OR/NOT, JOIN, GROUP BY λ“± 쑰건뢀 쿼리 μ „λ°˜μ—μ„œ 반볡적으둜 μž¬μ‚¬μš©λ˜λŠ” 핡심 문법이닀. [S1] ## πŸ’» μ½”λ“œ νŒ¨ν„΄ (Code patterns) Filter by text value (SQL): ```sql SELECT * FROM Customers WHERE Country = 'Mexico'; ``` Filter by numeric comparison (SQL): ```sql SELECT * FROM Customers WHERE CustomerID > 80; ``` ## βœ… 검증 μƒνƒœ 및 신뒰도 - **μƒνƒœ:** draft - **검증 단계:** conceptual - **좜처 신뒰도:** B (W3Schools β€” widely used educational reference, not a primary standards body) - **μ‹ λ’° 점수:** 0.90 - **쀑볡 검사 κ²°κ³Ό:** μ‹ κ·œ 생성 (New discovery) ## πŸ”— 지식 κ·Έλž˜ν”„ (Knowledge Graph) - **μƒμœ„/루트:** [[SQL Tutorial]] - **κ΄€λ ¨ κ°œλ…:** [[SQL Select]], [[SQL And]], [[SQL Like]], [[SQL Between]], [[SQL In]] - **μ°Έμ‘° λ§₯락:** 쑰건뢀 데이터 ν•„ν„°λ§μ˜ 기반 λ¬Έμ„œ β€” AND/OR/NOT, LIKE, BETWEEN, IN 챕터가 λͺ¨λ‘ 이 WHERE 절 문법을 ν™•μž₯ν•œλ‹€. ## πŸ“š 좜처 (Sources) - [S1] W3Schools β€” SQL WHERE Clause β€” https://www.w3schools.com/sql/sql_where.asp ## πŸ“ λ³€κ²½ 이λ ₯ (Change history) - 2026-07-04: Initial draft synthesized from the W3Schools "SQL WHERE Clause" page (Astra wiki-curation, P-Reinforce v3.1 format).