--- id: php-mysql-delete title: "PHP MySQL Delete" category: "Programming_Language" status: "draft" verification_status: "conceptual" canonical_id: "" aliases: ["DELETE FROM", "PHP MySQL μ‚­μ œ"] 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: ["php", "programming", "w3schools", "mysql", "delete"] raw_sources: ["https://www.w3schools.com/php/php_mysql_delete.asp"] applied_in: [] github_commit: "" --- # [[PHP MySQL Delete]] ## 🎯 ν•œ 쀄 톡찰 (One-line insight) Omitting the `WHERE` clause in a `DELETE` statement deletes EVERY record in the table β€” the source flags this with an explicit "NOTE" warning, since `DELETE FROM MyGuests` (without `WHERE id=3`) would wipe the entire table rather than doing nothing or erroring. [S1] ## 🧠 핡심 κ°œλ… (Core concepts) - **`DELETE FROM table WHERE condition`** β€” removes matching records. [S1] - **WHERE is what limits the blast radius** β€” omitting it deletes ALL records in the table. [S1] - **Executed like other write operations** β€” `$conn->query($sql)` (MySQLi OOP), `mysqli_query($conn, $sql)` (procedural), `$conn->exec($sql)` (PDO). [S1] ## πŸ“– μ„ΈλΆ€ λ‚΄μš© (Details) - Delete by ID: `$sql = "DELETE FROM MyGuests WHERE id=3"; if ($conn->query($sql) === TRUE) { echo "Record deleted successfully"; } else { echo "Error deleting record: " . $conn->error; }`. [S1] - PDO equivalent: `$sql = "DELETE FROM MyGuests WHERE id=3"; $conn->exec($sql); echo "Record deleted successfully";` wrapped in try/catch(PDOException). [S1] ## βš–οΈ λͺ¨μˆœ 및 μ—…λ°μ΄νŠΈ (Contradictions & updates) - **WHERE 절 μƒλž΅μ˜ 파괴적 κ²°κ³Ό**: WHERE μ ˆμ„ μƒλž΅ν•˜λ©΄ ν…Œμ΄λΈ”μ˜ λͺ¨λ“  λ ˆμ½”λ“œκ°€ μ‚­μ œλœλ‹€λŠ” 점이 λͺ…μ‹œμ  κ²½κ³ (NOTE)둜 강쑰됨. [S1] ## πŸ› οΈ 적용 사둀 (Applied in summary) ν˜„μž¬ 발견된 μ‹€μ œ 적용 사둀가 μ—†μŠ΅λ‹ˆλ‹€ β€” id=3 게슀트 λ ˆμ½”λ“œλ§Œ μ‚­μ œν•˜λŠ” 것이 μ•ˆμ „ν•œ 쑰건뢀 μ‚­μ œμ˜ ν‘œμ€€ νŒ¨ν„΄μ΄λ‹€. [S1] ## πŸ’» μ½”λ“œ νŒ¨ν„΄ (Code patterns) Deleting a specific record, never omitting WHERE (SQL/PHP): ```php $sql = "DELETE FROM MyGuests WHERE id=3"; // WHERE is mandatory to avoid deleting everything if ($conn->query($sql) === TRUE) { echo "Record deleted successfully"; } ``` ## βœ… 검증 μƒνƒœ 및 신뒰도 - **μƒνƒœ:** draft - **검증 단계:** conceptual - **좜처 신뒰도:** B (W3Schools β€” widely used educational reference, not a primary standards body) - **μ‹ λ’° 점수:** 0.90 - **쀑볡 검사 κ²°κ³Ό:** μ‹ κ·œ 생성 (New discovery) ## πŸ”— 지식 κ·Έλž˜ν”„ (Knowledge Graph) - **μƒμœ„/루트:** [[PHP Tutorial]] - **κ΄€λ ¨ κ°œλ…:** [[PHP MySQL Select Order By]], [[PHP MySQL Update]] - **μ°Έμ‘° λ§₯락:** λ ˆμ½”λ“œ μ‚­μ œ β€” λ ˆμ½”λ“œ μˆ˜μ •(Update) μ±•ν„°λ‘œ 이어짐. ## πŸ“š 좜처 (Sources) - [S1] W3Schools β€” PHP MySQL Delete Data β€” https://www.w3schools.com/php/php_mysql_delete.asp ## πŸ“ λ³€κ²½ 이λ ₯ (Change history) - 2026-07-04: Initial draft synthesized from the W3Schools "PHP MySQL Delete Data" page (Astra wiki-curation, P-Reinforce v3.1 format).