How to prevent duplicate entries into db table when storing API data

Hi, i have been working with an API to consume data and store in a db table, but i wanted not to store duplicate entries when second or more call goes to the API and store the data.

I did tried to put querying the table and condition to check if data exist and then matching a unique column and then based on the matching created the update action but it does not worked.

ex: if table 1 has column: id, code, rate where i store data from API, if I’m requesting second time or more, API data structure: {$key, $value} $key is equivalent to ‘code’

i did like this, but no luck…

Community Page
Last updated: