MySQL Join with multiple conditions

后端 未结 4 1710
伪装坚强ぢ
伪装坚强ぢ 2020-12-23 11:34

I have a problem with an sql query, actually a simple query but I can\'t figure up what am I missing, so I came to ask your help... So, what i have to do

I have two

4条回答
  •  予麋鹿
    予麋鹿 (楼主)
    2020-12-23 12:05

    You can group conditions with parentheses. When you are checking if a field is equal to another, you want to use OR. For example WHERE a='1' AND (b='123' OR b='234').

    SELECT u.*
    FROM rooms AS u
    JOIN facilities_r AS fu
    ON fu.id_uc = u.id_uc AND (fu.id_fu='4' OR fu.id_fu='3')
    WHERE vizibility='1'
    GROUP BY id_uc
    ORDER BY u_premium desc, id_uc desc
    

提交回复
热议问题