sql - MySQL: Code To Compare 2 Tables, Then If row is the same update Master Date -


I have two tables, they are called Master and NewData, the schema on both tables is exactly the same and there are field names in it: CODE, SERIAL, model, VALIDATED_DATE.

I want to see if the value of the CODE field is present in the NEWDATA table and the master table if they are in both tables, then I want to update the Master of Table on VALIDATED_DATE.

I have lots of records so I'm curious what's the fastest way to do this?

Thank you!

  update master m also includes n.code = M.code on newdata n .validated_date = now ()  

The code column should be indexed for this task to work efficiently. Given that it should be fast, which is much faster than the other methods mentioned above (unless you are running mysql 5.4, the correlated subquery execution of mysql is basically completely unused).


Comments

Popular posts from this blog

asp.net - Javascript/DOM Why is does my form not support submit()? -

sockets - Delphi: TTcpServer, connection reset when reading -

javascript - Classic ASP "ExecuteGlobal" statement acting differently on two servers -