mysql - AND clause after an OR clause -
i trying running mysql query "find_in_set" in it.
running query works, need find "user_optin" equal 1.
running query finds people have user_optin "0"
select `user_id`, `user_firstname`, `user_surname`, `user_email`, `user_type`, `user_optin` (`users`) `user_type` = 'volunteer' , 1 <=find_in_set(1, user_interests) or 1 <=find_in_set(2, user_interests) or 1 <=find_in_set(5, user_interests) or 1 <=find_in_set(6, user_interests) or 1 <=find_in_set(7, user_interests) or 1 <=find_in_set(8, user_interests) or 1 <=find_in_set(10, user_interests) , 1 <=find_in_set(1, user_activities) or 1 <=find_in_set(2, user_activities) or 1 <=find_in_set(4, user_activities) or 1 <=find_in_set(5, user_activities) or 1 <=find_in_set(11, user_activities) or 1 <=find_in_set(12, user_activities) or 1 <=find_in_set(14, user_activities) , `user_optin` = '1'
if take "or's" out of query user_optin part of query works.
is there anyway @ can create user_optin explict find "1" entry, not "0" entry.
i didn't design database , realise find_in_set not best method mysql database queries.
cheers
add other clauses within ()
seperate them final and
.
select `user_id`, `user_firstname`, `user_surname`, `user_email`, `user_type`, `user_optin` (`users`) ( `user_type` = 'volunteer' , 1 <= find_in_set(1, user_interests) or 1 <= find_in_set(2, user_interests) or 1 <= find_in_set(5, user_interests) or 1 <= find_in_set(6, user_interests) or 1 <= find_in_set(7, user_interests) or 1 <= find_in_set(8, user_interests) or 1 <= find_in_set(10, user_interests) , 1 <= find_in_set(1, user_activities) or 1 <= find_in_set(2, user_activities) or 1 <= find_in_set(4, user_activities) or 1 <= find_in_set(5, user_activities) or 1 <= find_in_set(11, user_activities) or 1 <= find_in_set(12, user_activities) or 1 <= find_in_set(14, user_activities) ) , `user_optin` = '1'
mysql
No comments:
Post a Comment