Hi everyone trying to put together an update query based on this select query.
Essentially I want to do is update u.status to 0 where the 2 last login critera is met.
Cheers for any advice.
Whilst @Mrs_Fatherjack is right, I just wanted to add that if the join is important here, then it should also be included in the update - there may be employees in the table_user table that are not in the table_employee table - it's a subtle difference
That will update exactly the same subset of records as you got when you ran the result.
Also to reiterate @Pavel 's point too - should those last_login datetimes be within parentheses?
answered Jun 03, 2011 at 06:12 AM
Kev Riley ♦♦
Remember when you name columns that are the system as system defined e.g. status you need to put square brakes () round them. See the status field above.
I have put a transaction round this as it's always sensible to use a transaction when running a script, if everything goes OK you then commit it, if not roll it back and nothing is lost.