What is the difference between INSERT and UPDATE in SQL?

INSERT is used to add new records to a table in a database, while UPDATE is used to modify existing records in a table. If you want to add a new record to a table, you would use INSERT. If you want to update an existing record in a table, you would use UPDATE.

// Example of using INSERT in SQL
$sql = "INSERT INTO users (name, email) VALUES ('John Doe', 'john.doe@example.com')";
$result = mysqli_query($conn, $sql);

// Example of using UPDATE in SQL
$sql = "UPDATE users SET email = 'johndoe@example.com' WHERE name = 'John Doe'";
$result = mysqli_query($conn, $sql);