Does row exist
Posted on 2014-09-28
I've been trying to figure out if/how its possible to check if a row exists in another table, but only if 'Removed' = null.
So for example:-
Contacts(Number, Name, Company, Office)
Features(ID, Number, Feature, added, removed)
What Im trying to do is something like:-
Select Company, Office, Number, iif((select count(*) from `features` where ((`Features'.`Number`=`Contacts`.`Number`) and (`Features`.`removed` = null) and (`Features`.`Feature`='Project Manager'))>1,true,false)
So the idea is to display all the `Feature` in the Features table that have `removed` as null, and return false, if it doesn't exist, but if the `feature`.`removed` isnt null then still return false.
My first thought was to try and do this as a PHP function, but this would involve multiple PHP query calls so hugely inefficient.
I hope this explains what Im trying to do enough for someone to point me in the right direction?