How to priorities or condition over other conditions mysql? -


i have sql query using sub queries.

select t.id subjects t  t.topic_id in (13,11)    , t.id  not in (select subject_id                      user_visited_subjects uvs                     uvs.user_id = 3 )     or t.id in (select subject_id               user_subject_suggestions uss                uss.user_id = 3 )   limit 10 

i want give priority or conditions means sql should check if there record in query

or t.id in (select subject_id user_subject_suggestions uss uss.user_id = 3 ) 

then check other conditions.

please advise.

thanks

just use parentheses.

example:

select t.id subjects t  t.id in (select subject_id user_subject_suggestions uss uss.user_id = 3 )     or (t.topic_id in (13,11)          , t.id  not in (select subject_id user_visited_subjects uvs uvs.user_id = 3 )) limit 10 

Comments

Popular posts from this blog

angular - Ionic slides - dynamically add slides before and after -

minify - Minimizing css files -

Add a dynamic header in angular 2 http provider -