Henk Rensenbrink Henk Rensenbrink - 1 year ago 70
MySQL Question

Remove row if not exists in variable

Good afternoon,

currently I am trying to remove a row from my database if the value does not exist in my variable.
I am calling a variable $blsrowP["field_zipcode_value"] which returns all zipcodes from our database. Another database holds these same zipcodes.
I want to compare these zipcodes from my variable with the new database and remove the zipcodes that are not listed inside this variable.

I am not comparing two different databases, but just the variable with my database.
I tried searching online but I can only find comparing two different database tables. Thanks.

Answer Source

If you can pass the variables in a not in query you can achieve this (if I understood correctly). Develop the below query in your program/script and get the list from the first database and delete it from the second database.

Delete * from tabname where column not in (<provide your variable list>)

If it won't help please provide more details.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download