Cron task with php, how to randomly select a row when "id" = 20, transfer the row to another table and then truncate the old table
Cron task with php, how to randomly select a row when "id" = 20, transfer the row to another table and then truncate the old table
Can someone give me some direction on how to write this type of code?
it is mysql, id is set by phpmysql aut开发者_Python百科o_increment sorry!
When id
is auto_increment
then you could not randomly select a row, because you select only one row. By default PHP extensions for mysql don't accept multiple statements. So when I understand you right it would be done with two SQL statements
INSERT INTO <table2> (<cols>) SELECT <cols> FROM <table1> WHERE id=20
TRUNCATE TABLE <table2>
精彩评论