Welcome to WebmasterWorld Guest from 188.8.131.52 , register , free tools , login , search , pro membership , help , library , announcements , recent posts , open posts Pubcon Platinum Sponsor 2014
PHP MySQL report sparkes Hi Guys, I have an array of data, that I want to compare against a field in my db, and drag out the items in the db that are NOT in the array.. Any ideas please... TIA
Hi Sparkes, Welcome to WebmasterWorld select * from table where field not in ("item1","item2","item3") and so on. You can create a comma seperated list of your array items by using php's implode function
perfect, it's too easy to start looking at complicated solutions, when a nice simple one liner is there.. Thank v much sparkes
Ahh one possible stumbling block, the array can have over 1000 elements ! Will that be ok ? enigma1
There is a mysql setting "max_allowed_packet" and puts a cap to the max length of your mysql statement. Default is 1MB so you should be ok. Anyango
You might want to store those 1000+ items in a table and then run a join to grab only the results that dont have those vlaues. if the table is large then this IN() with 1k+ values might slow your query down sparkes
Am pleased to say that it works ok, no significant speed issue. In reality it doesn't pull that much data.. The DB only has 9k rows, so nothing to worry about there..