用php的Cron任务,如何随机选择一行时"id"= 20,将该行转移到另一个表,然后截断旧表


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,如何随机选择一行,当"id" = 20,转移到另一个表,然后截断旧表

有人能给我一些关于如何写这种类型的代码方向吗?

是mysql, id是由phpmysql auto_increment设置的。

idauto_increment时,您不能随机选择一行,因为您只选择了一行。默认情况下,mysql的PHP扩展不接受多个语句。所以当我理解你正确的时候,它将用两个SQL语句完成

INSERT INTO <table2> (<cols>) SELECT <cols> FROM <table1> WHERE id=20
TRUNCATE TABLE <table2>