Mysql Update query

The SQL UPDATE Statement
The UPDATE statement is used to update existing records in a table.

Single table update
Syntex: 
UPDATE [table1_name] set t1.column='some values' where condition

Example :
here update statename column of state table.

Update state set statename='India' where pincode like '600%';

Inner join Updates

syntex:

UPDATE [table1_name] AS t1 
INNER JOIN [table2_name] AS t2 
ON t1.[column1_name] = t2.[column1_name] 
SET t1.[column2_name] = t2.[column2_name] where condition;

Example: 


UPDATE employees em
INNER JOIN  Mark ON em.Grade = Mark.Grade
SET em.salary = em.salary + em.Grade/ percentage;

Post a Comment

0 Comments