--- id: php-mysql-select-where title: "PHP MySQL Select Where" category: "Programming_Language" status: "draft" verification_status: "conceptual" canonical_id: "" aliases: ["WHERE clause", "PHP MySQL 필터링"] duplicate_of: "" source_trust_level: "B" confidence_score: 0.89 created_at: 2026-07-04 updated_at: 2026-07-04 review_reason: "" merge_history: [] tags: ["php", "programming", "w3schools", "mysql", "where"] raw_sources: ["https://www.w3schools.com/php/php_mysql_select_where.asp"] applied_in: [] github_commit: "" --- # [[PHP MySQL Select Where]] ## 🎯 ν•œ 쀄 톡찰 (One-line insight) This chapter reuses the EXACT same PHP structure as the plain SELECT chapter β€” only the SQL string itself changes (`... WHERE lastname='Doe'` appended) β€” demonstrating that filtering logic lives entirely in the SQL layer, with zero changes needed to the PHP fetch/loop code around it. [S1] ## 🧠 핡심 κ°œλ… (Core concepts) - **`WHERE column operator value`** β€” filters records matching a condition. [S1] - **Same PHP wrapper as plain SELECT** β€” connection, `query()`, `num_rows`/`rowCount()` check, `fetch_assoc()`/`fetch()` loop are all identical; only the SQL string differs. [S1] ## πŸ“– μ„ΈλΆ€ λ‚΄μš© (Details) - Filtered select: `$sql = "SELECT id, firstname, lastname FROM MyGuests WHERE lastname='Doe'"; $result = $conn->query($sql); if ($result->num_rows > 0) { while($row = $result->fetch_assoc()) { echo "id: " . $row["id"]. " - Name: " . $row["firstname"]. " " . $row["lastname"]. "
"; } }`. [S1] ## βš–οΈ λͺ¨μˆœ 및 μ—…λ°μ΄νŠΈ (Contradictions & updates) μ†ŒμŠ€μ—μ„œ λͺ¨μˆœλ˜λŠ” μ •λ³΄λŠ” λ°œκ²¬λ˜μ§€ μ•ŠμŒ. ## πŸ› οΈ 적용 사둀 (Applied in summary) ν˜„μž¬ 발견된 μ‹€μ œ 적용 사둀가 μ—†μŠ΅λ‹ˆλ‹€ β€” lastname='Doe' 쑰건으둜 νŠΉμ • 게슀트만 μ‘°νšŒν•˜λŠ” 것이 ν•„ν„°λ§μ˜ λŒ€ν‘œ μ‹€μ „ 사둀닀. [S1] ## πŸ’» μ½”λ“œ νŒ¨ν„΄ (Code patterns) Filtering results with WHERE, same PHP structure as plain SELECT (PHP/MySQLi): ```php $sql = "SELECT id, firstname, lastname FROM MyGuests WHERE lastname='Doe'"; $result = $conn->query($sql); if ($result->num_rows > 0) { while ($row = $result->fetch_assoc()) { echo "id: " . $row["id"] . " - Name: " . $row["firstname"] . " " . $row["lastname"] . "
"; } } ``` ## βœ… 검증 μƒνƒœ 및 신뒰도 - **μƒνƒœ:** draft - **검증 단계:** conceptual - **좜처 신뒰도:** B (W3Schools β€” widely used educational reference, not a primary standards body) - **μ‹ λ’° 점수:** 0.89 - **쀑볡 검사 κ²°κ³Ό:** μ‹ κ·œ 생성 (New discovery) ## πŸ”— 지식 κ·Έλž˜ν”„ (Knowledge Graph) - **μƒμœ„/루트:** [[PHP Tutorial]] - **κ΄€λ ¨ κ°œλ…:** [[PHP MySQL Select]], [[PHP MySQL Select Order By]] - **μ°Έμ‘° λ§₯락:** WHERE 쑰건 필터링 β€” ORDER BY μ •λ ¬(Select Order By) μ±•ν„°λ‘œ 이어짐. ## πŸ“š 좜처 (Sources) - [S1] W3Schools β€” PHP MySQL The WHERE Clause β€” https://www.w3schools.com/php/php_mysql_select_where.asp ## πŸ“ λ³€κ²½ 이λ ₯ (Change history) - 2026-07-04: Initial draft synthesized from the W3Schools "PHP MySQL The WHERE Clause" page (Astra wiki-curation, P-Reinforce v3.1 format).