Update table 1 with table 2 then truncate table 2

keyclePlanymn

New Member
As I've posted in another query, I have an MYSQL table containing Tweets, and use PHP to populate it. To ensure that there are no duplicate posts it checks the last ID in the table before updating, which I think is why when trying to get it to check the retweet_count it fails (it's ignoring tweets already stored).My work around is to use the same script to also populate a second table and then run the following two SQL commands:\[code\] UPDATE table1 JOIN table2 ON table2.col1 = table1.col1 SET table1.col2 = table2.col2;\[/code\]followed by\[code\] TRUNCATE TABLE table2;\[/code\]Which updates the first table and then empties (not delete, just truncates) the second so I can repeat.The question is how would that be written in PHP such that the JOIN command would execute first and then the TRUNCATE command would execute?Thanks
 
Back
Top