MySQL “Or” Condition

后端 未结 5 438
攒了一身酷
攒了一身酷 2020-12-29 21:38

Check out this MySQL Query and then I\'ll show you what I really want it to do...

mysql_query(\"
SELECT * FROM Drinks WHERE
    email=\'$Email\'         


        
5条回答
  •  时光取名叫无心
    2020-12-29 21:56

    Your question is about the operator precedences in mysql and Alex has shown you how to "override" the precedence with parentheses.

    But on a side note, if your column date is of the type Date you can use MySQL's date and time functions to fetch the records of the last seven days, like e.g.

    SELECT
      *
    FROM
      Drinks
    WHERE
      email='$Email'
      AND date >= Now()-Interval 7 day
    

    (or maybe Curdate() instead of Now())

提交回复
热议问题