Welcome to the question whether the database data needs to be updated.

is such a scenario:
1. The data requested from a third party is stored in my own database, and I do a scheduled task
2. I first go to query my database, simply insert the update operation, if else operation
3. But what I"m thinking about is how to compare the two pieces of data. If my database data is the same as the one requested, I won"t update the database.
how can I use it instead? Solve the puzzle

Php
Mar.13,2021

in your second step, you have queried whether there is this record in your database. Now that you have checked it, it is good to compare it. Compare the fields you want to query with the fields returned by the third party. Update if different, otherwise you don't have to do anything.

if you don't want to query direct comparison, you can use sql's update plus where condition, for example:

update table1 set col = "baba" where id=3 AND col <> "baba"

add one more if judgment, or add multiple where conditional judgments to the sql statement.

MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1bf5e1c-31fbc.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1bf5e1c-31fbc.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?