MySQL uses SQL as its official query language which is an advantage especially if you're already familiar with the different Database Management System that uses SQL. It contains several commands such as the Data Definition Language (DDL) used to create and structure your database and the Data Manipulation Language (DML) used to manipulate data in your database. In this article, we will be dealing with the
SQL UPDATE for now.
There will be cases where in you need to change or modify existing data in your table. Let's say, you mistakenly typed your name and want to correct it. You can achieved it using the
SQL UPDATE command. This will change or update the value currently found in your database table.
SYNTAX FOR SQL UPDATE
UPDATE table_name SET column_name1='value1',column_name2='value2' [WHERE condition];
WHERE CLAUSE is the keyword used to limit the rows affected by the query.
STUDENT TABLE
The table above contains the list of students. Now, we will use the
SQL UPDATE command by changing the firstname from RIZA to MAY.
SAMPLE SQL UPDATE
UPDATE STUDENT SET firstname='May' WHERE stud_id='1';
The code above will change the first name from Riza to May with the stud_id of 1.
UPDATE IN MYSQL: Update Data in a Table in MySQL
No comments:
Post a Comment