Can LIMIT be used in conjunction with other SQL statements besides SELECT in PHP?
Yes, LIMIT can be used with other SQL statements besides SELECT in PHP. For example, you can use LIMIT with DELETE or UPDATE statements to limit the number of rows affected by the query. This can be useful when you only want to delete or update a certain number of records in a table. Example PHP code snippet:
<?php
// Connect to database
$pdo = new PDO('mysql:host=localhost;dbname=test', 'username', 'password');
// Example of using LIMIT with DELETE statement
$sql = "DELETE FROM users WHERE status = 'inactive' LIMIT 10";
$pdo->exec($sql);
// Example of using LIMIT with UPDATE statement
$sql = "UPDATE products SET price = price * 1.1 WHERE category = 'electronics' LIMIT 5";
$pdo->exec($sql);
?>