---
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).