
- Learn MySQL
- MySQL - Home
- MySQL - Introduction
- MySQL - Installation
- MySQL - Administration
- MySQL - PHP Syntax
- MySQL - Connection
- MySQL - Create Database
- MySQL - Drop Database
- MySQL - Select Database
- MySQL - Data Types
- MySQL - Create Tables
- MySQL - Drop Tables
- MySQL - Insert Query
- MySQL - Select Query
- MySQL - Where Clause
- MySQL - Update Query
- MySQL - Delete Query
- MySQL - Like Clause
- MySQL - Sorting Results
- MySQL - Using Join
- MySQL - NULL Values
- MySQL - Regexps
- MySQL - Transactions
- MySQL - Alter Command
- MySQL - Indexes
- MySQL - Temporary Tables
- MySQL - Clone Tables
- MySQL - Database Info
- MySQL - Using Sequences
- MySQL - Handling Duplicates
- MySQL - SQL Injection
- MySQL - Database Export
- MySQL - Database Import
How can I update a table using prepare statements?
It can be understood with the help of following the example in which we have updated the table named ‘Student’, having the following data, by using prepared statement −
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)
- Related Articles
- How can I create a table and insert values in that table using prepare statements?
- How can I prepare a dish using both vermicelli and seviya?
- How can I create a stored procedure to update values in a MySQL table?
- What kind of SQL statements can be used to prepare statements?
- How can you update certain values in a table in MySQL using Python?
- How can we update values in a MySQL table?
- How can I update MySQL table after quoting the values of a column with a single quote?
- How can I update a field in a MySQL database table by adding a value in the second table with a value from the first table?
- How can I update child objects in MongoDB?
- How can we update the values in one MySQL table by using the values of another MySQL table?
- How can I update child objects in MongoDB database?
- How can I update the boolean values in MySQL?
- How can we update any value in MySQL view as we can update the values in MySQL table?
- Combine MySQL UPDATE STATEMENTS?
- How do I prepare for a Python interview?

Advertisements