I have 2 tables for my game script, one is a database of all the weapons ingame (db_firearms) and the other is a list of the weapons in the stores (store_firearms).
db_firearms
(the store field says whether it will appear in stores, 0 = no, 1=yes)
id name store
-----------------------
1 Pistol 1
2 Shotgun 1
3 Sniper 0
store_firearms
(weapon field relates to the id of the weapon in db_firearms)
id city weapon
-----------------------
1 Miami 1
2 Miami 2
3 New York 2
What I want to do, is populate the store_firearms table with each MISSING weapon from the db_firearms table with store=1 (where city= $city).
What’s the best way to do a query for this in mySQL?
EDIT Completely botched that first try, using
NOT EXISTSworks.If $city were ‘New York’, this would insert ‘New York’, 1 into store_firearms