I am performing a filter by selected value this how my database looks like:
contactgroup media gender age isdelete married children driverslicens restatus retype
-----------------------------------------------------------
contactgroup1 SMS Male 28 0 yes yes yes owner apart
contactgroup1 SMS Female 26 0 no null no rent house
contactgroup2 SMS Male 32 0 null no null owner null
contactgroup2 SMS Male 38 0 yes yes no null null
This is my query:
SELECT * FROM contact
where isdeleted = 0
AND contactgroup in ('Contactgroup1', '')
and media = 'sms'
AND (`gender` = 'female' OR `gender` = 'male' OR `gender` is null)
AND (`married` = 'yes' OR `married` = 'no' OR `married` is null)
AND (`children` = 'yes' OR `children` = 'no' OR `children` is null)
AND (`driverslicense` = 'yes' OR `driverslicense` = 'no' OR `driverslicense` is null)
AND (`retype` = 'owner' OR `retype` = 'renting' OR `retype` is null)
AND (`restatus` = 'apart' OR `restatus` = 'house' OR `restatus` is null)
and age BETWEEN 18 AND 60
This query should show the data regarding the contactgroup1, but its showing all the four data can anyone tell me why it’s showing all the data where I went wrong?