Update query in mysql

Update query in mysql

Blog Bustle 28/01/2020

What is update query in mysql?

update query is used to update records in mysql table. You can update one record or multiple records at a time.

Update query syntax

update table_name set column_1=value_1, column_2=value2, column_3=value3,.... ;

update table_name set column_1=value_1, column_2=value2, column_3=value3,.... where condition;

You can specify one or more condition by using where clause and combine more conditions by using 'and/or' operator.

update student set name='sagar' where mobile=1234567890 and email='mohit@gmail.com'

in this mysql update query both condition should be true.

update student set name='sagar' where mobile=1234567890 or email='mohit@gmail.com'

in this mysql update query atleast one condition should be true.

There are two methods to write update query in mysql:

Method 1: When where condition is given

we have student table

update query in mysql

we want to update all email where mobile is 1234567890 then query will be

update student set email='user@gmail.com' where mobile='1234567890'

update query in mysql

Method 2: When where condition is not given

we are going to update all name and mobile in student table without any condition and query will be

update student set name='karan',mobile=9999999999

update query in mysql

Other important links

Insert query in mysql

Delete query in mysql

Select query in mysql

Difference between sql and mysql

Create Database in mysql

Update query in mysql searches:

Tags: #mysql