小编Dan*_*iil的帖子

SQL使用新数据更新整个表

我每隔15分钟运行一次查询,从API检索新数据并将此数据存储在我的数据库中.

因此,每隔15分钟,我想将新数据存储在表中,并删除该表中的所有旧数据.

我目前正在使用以下方法:

$sql = "DELETE FROM self_user_follower
        INSERT INTO self_user_follower (username, profile_picture, full_name, user_id, last_updated)
        VALUES (:query_username, :query_profile_picture, :query_full_name, :query_user_id, :query_last_updated)";
Run Code Online (Sandbox Code Playgroud)

但它给了我以下错误:

Array
(
    [0] => 42000
    [1] => 1064
    [2] => You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'INSERT INTO self_user_follower (username, profile_picture, full_name, user_id, l' at line 2
)
query_error
Run Code Online (Sandbox Code Playgroud)

这是最好的方法,还是有更好,更清洁的方法来做到这一点?

php mysql sql sql-delete

0
推荐指数
1
解决办法
52
查看次数

标签 统计

mysql ×1

php ×1

sql ×1

sql-delete ×1