how to use update inner join

Published on Author bloggerfive

Even though i familiar with update statement , i could not able to construct query if had encounter the scenario that needed to write update with inner join .

Because , the syntax of update inner join is slightly different from update statement alone . Hope the following code snippets would help you too to understand that .

Syntax :

UPDATE table_name  a
INNER JOIN table_name  b ON a.columnName=b.columnName
SET   a.columnName = ‘String’  
WHERE date(a.columnName)=’YYYY-MM-DD’  
and b.columnName like ‘%SEARCH_TEXT%’;

Example :

UPDATE order_details  a
INNER JOIN product_details  b ON a.orderId=b.orderId
SET   a.productName = ‘Complan’  
WHERE date(a.lastModifiedDate)>=’2013-12-09′  
and b.columnName like ‘%Complan%’; —  junior complan

But In case of  update query without inner join 

UPDATE  product_details  a
SET   a.productName = ‘Complan’  
WHERE a.columnName like ‘%Complan%’; —  junior complan