Henk Rensenbrink
Henk Rensenbrink

Reputation: 87

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.

Upvotes: 0

Views: 53

Answers (1)

Adarsh
Adarsh

Reputation: 726

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.

Upvotes: 1

Related Questions