Welcome to WebmasterWorld Guest from 54.80.189.255

Forum Moderators: open

Message Too Old, No Replies

REPLACE INTO. (if tableA.updated > tableB.updated?)

     
3:37 am on Feb 11, 2017 (gmt 0)

Senior Member

WebmasterWorld Senior Member 5+ Year Member Top Contributors Of The Month

joined:Mar 15, 2013
posts: 710
votes: 58


I have 2 tables with identical structures, and the last column is "updated". Column "updated" is timestamp on update CURRENT_TIMESTAMP.

tableB collects "flagged" data submitted from users, for a moderator to review before moving it to tableA (if approved).

Here's the code I currently use:


@var_user = 'whatever';

REPLACE INTO tableA
SELECT * FROM tableB
WHERE username=@var_user
LIMIT 1;


Can you guys suggest how I might change it to only REPLACE if tableB.updated is newer than tableA.updated? Keeping in mind that tableA.updated may not exist at all.

TIA!
 

Join The Conversation

Moderators and Top Contributors

Hot Threads This Week

Featured Threads

Free SEO Tools

Hire Expert Members