How can the WHERE clause be correctly utilized in an UPDATE statement to avoid multiple entries in the database?

To avoid multiple entries in the database when using an UPDATE statement, the WHERE clause should be used to specify which specific record should be updated. By including specific criteria in the WHERE clause, only the matching record will be updated, preventing multiple entries from being affected.

<?php
// Connect to the database
$pdo = new PDO('mysql:host=localhost;dbname=your_database', 'username', 'password');

// Update a specific record in the database
$id = 1;
$newValue = 'New value';

$stmt = $pdo->prepare("UPDATE your_table SET column_name = :value WHERE id = :id");
$stmt->bindParam(':value', $newValue);
$stmt->bindParam(':id', $id);
$stmt->execute();
?>