--- id: sql-and title: "SQL And" category: "Database" status: "draft" verification_status: "conceptual" canonical_id: "" aliases: ["SQL AND Operator", "AND 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", "and", "operators", "where"] raw_sources: ["https://www.w3schools.com/sql/sql_and.asp"] applied_in: [] github_commit: "" --- # [[SQL And]] ## ๐ŸŽฏ ํ•œ ์ค„ ํ†ต์ฐฐ (One-line insight) The AND operator filters records so that a row is returned only when ALL chained conditions in the WHERE clause are true. [S1] ## ๐Ÿง  ํ•ต์‹ฌ ๊ฐœ๋… (Core concepts) - **AND operator** โ€” combines multiple conditions in a WHERE clause; a record is returned only if every condition is TRUE. [S1] - **Syntax** โ€” `SELECT ... FROM table_name WHERE condition1 AND condition2 AND condition3 ...;`. [S1] - **AND vs. OR** โ€” AND requires all conditions true; OR requires at least one condition true. [S1] - **Combining AND and OR** โ€” parentheses control evaluation grouping when mixing the two operators. [S1] ## ๐Ÿงฉ ์ถ”์ถœ๋œ ํŒจํ„ด (Extracted patterns) - **Parenthesize when mixing AND/OR** โ€” `WHERE Country = 'Spain' AND (CustomerName LIKE 'G%' OR CustomerName LIKE 'R%')` gives the intended grouped result; omitting the parentheses changes which rows match because AND/OR precedence is not what the un-parenthesized reading suggests. [S1] ## โš–๏ธ ๋น„๊ต ๋ฐ ์„ ํƒ ๊ธฐ์ค€ (Comparison & decision criteria) | ํ•ญ๋ชฉ (Option) | ์žฅ์  | ๋‹จ์  | ์–ธ์ œ ์„ ํƒ | |---|---|---|---| | **๊ด„ํ˜ธ๋กœ ๊ทธ๋ฃนํ™”** | ์˜๋„ํ•œ ๋Œ€๋กœ ์ •ํ™•ํ•œ ๊ฒฐ๊ณผ, ๊ฐ€๋…์„ฑ ํ–ฅ์ƒ | ์ฝ”๋“œ๊ฐ€ ์•ฝ๊ฐ„ ๊ธธ์–ด์ง | AND/OR๋ฅผ ์„ž์–ด ์“ธ ๋•Œ ํ•ญ์ƒ | | **๊ด„ํ˜ธ ์ƒ๋žต** | ์งง์Œ | ์—ฐ์‚ฐ์ž ์šฐ์„ ์ˆœ์œ„๋กœ ์ธํ•ด ์˜๋„์™€ ๋‹ค๋ฅธ ๊ฒฐ๊ณผ๊ฐ€ ๋‚˜์˜ฌ ์œ„ํ—˜ | ๋‹จ์ผ ์—ฐ์‚ฐ์ž๋งŒ ์‚ฌ์šฉํ•  ๋•Œ | ## ๐Ÿ“– ์„ธ๋ถ€ ๋‚ด์šฉ (Details) - Filter on two conditions: `SELECT * FROM Customers WHERE Country = 'Spain' AND CustomerName LIKE 'G%';`. [S1] - Filter on three conditions: `WHERE Country = 'Brazil' AND City = 'Rio de Janeiro' AND CustomerID > 50;`. [S1] - Mixed AND/OR, correctly grouped with parentheses: `WHERE Country = 'Spain' AND (CustomerName LIKE 'G%' OR CustomerName LIKE 'R%');` โ€” without the parentheses, the same text returns a different (wider) result set, since it becomes "Spain AND starts-with-G" OR "starts-with-R regardless of country". [S1] ## โš–๏ธ ๋ชจ์ˆœ ๋ฐ ์—…๋ฐ์ดํŠธ (Contradictions & updates) ์†Œ์Šค์—์„œ ๋ชจ์ˆœ๋˜๋Š” ์ •๋ณด๋Š” ๋ฐœ๊ฒฌ๋˜์ง€ ์•Š์Œ. ๋‹ค๋งŒ ๊ด„ํ˜ธ ์œ ๋ฌด์— ๋”ฐ๋ผ ๋™์ผํ•ด ๋ณด์ด๋Š” ์กฐ๊ฑด์‹์ด ๋‹ค๋ฅธ ๊ฒฐ๊ณผ๋ฅผ ๋‚ผ ์ˆ˜ ์žˆ๋‹ค๋Š” ์ ์ด ์†Œ์Šค ๋‚ด์—์„œ ์ง์ ‘ ๊ฒฝ๊ณ ๋จ. [S1] ## ๐Ÿ› ๏ธ ์ ์šฉ ์‚ฌ๋ก€ (Applied in summary) ํ˜„์žฌ ๋ฐœ๊ฒฌ๋œ ์‹ค์ œ ์ ์šฉ ์‚ฌ๋ก€๊ฐ€ ์—†์Šต๋‹ˆ๋‹ค โ€” WHERE ์ ˆ ๋‹ค์ค‘ ์กฐ๊ฑด ํ•„ํ„ฐ๋ง์—์„œ OR/NOT๊ณผ ํ•จ๊ป˜ ๊ฐ€์žฅ ๋นˆ๋ฒˆํžˆ ์žฌ์‚ฌ์šฉ๋˜๋Š” ์—ฐ์‚ฐ์ž๋‹ค. [S1] ## ๐Ÿ’ป ์ฝ”๋“œ ํŒจํ„ด (Code patterns) Multiple AND conditions (SQL): ```sql SELECT * FROM Customers WHERE Country = 'Brazil' AND City = 'Rio de Janeiro' AND CustomerID > 50; ``` Correctly grouped AND + OR (SQL): ```sql SELECT * FROM Customers WHERE Country = 'Spain' AND (CustomerName LIKE 'G%' OR CustomerName LIKE 'R%'); ``` ## โœ… ๊ฒ€์ฆ ์ƒํƒœ ๋ฐ ์‹ ๋ขฐ๋„ - **์ƒํƒœ:** draft - **๊ฒ€์ฆ ๋‹จ๊ณ„:** conceptual - **์ถœ์ฒ˜ ์‹ ๋ขฐ๋„:** B (W3Schools โ€” widely used educational reference, not a primary standards body) - **์‹ ๋ขฐ ์ ์ˆ˜:** 0.90 - **์ค‘๋ณต ๊ฒ€์‚ฌ ๊ฒฐ๊ณผ:** ์‹ ๊ทœ ์ƒ์„ฑ (New discovery) ## ๐Ÿ”— ์ง€์‹ ๊ทธ๋ž˜ํ”„ (Knowledge Graph) - **์ƒ์œ„/๋ฃจํŠธ:** [[SQL Tutorial]] - **๊ด€๋ จ ๊ฐœ๋…:** [[SQL Where]], [[SQL Or]], [[SQL Not]] - **์ฐธ์กฐ ๋งฅ๋ฝ:** WHERE ์ ˆ ๋‹ค์ค‘ ์กฐ๊ฑด ๊ฒฐํ•ฉ์˜ ๊ธฐ๋ณธ ์—ฐ์‚ฐ์ž โ€” OR/NOT๊ณผ ์„ธํŠธ๋กœ ์ดํ•ดํ•ด์•ผ ํ•œ๋‹ค. ## ๐Ÿ“š ์ถœ์ฒ˜ (Sources) - [S1] W3Schools โ€” SQL AND Operator โ€” https://www.w3schools.com/sql/sql_and.asp ## ๐Ÿ“ ๋ณ€๊ฒฝ ์ด๋ ฅ (Change history) - 2026-07-04: Initial draft synthesized from the W3Schools "SQL AND Operator" page (Astra wiki-curation, P-Reinforce v3.1 format).