可以透過以下範例來理解,在該範例中,我們使用準備好的語句更新了名為「Student」的表,其中包含以下資料-
mysql> Select * from Student; +------+-------+ | Id | Name | +------+-------+ | 1 | Ram | | 2 | Shyam | | 3 | Mohan | +------+-------+ 3 rows in set (0.00 sec) mysql> PREPARE stmt11 FROM 'UPDATE Student SET Name = ? WHERE Id = ?'; Query OK, 0 rows affected (0.03 sec) Statement prepared mysql> SET @A = 'Sohan', @B = 3; Query OK, 0 rows affected (0.00 sec) mysql> EXECUTE Stmt11 USING @A, @B; Query OK, 1 row affected (0.05 sec) mysql> Select * from student; +------+-------+ | Id | Name | +------+-------+ | 1 | Ram | | 2 | Shyam | | 3 | Sohan | +------+-------+ 3 rows in set (0.00 sec)
以上是如何使用準備語句更新表格?的詳細內容。更多資訊請關注PHP中文網其他相關文章!