Results 1 to 2 of 2

Thread: If in sql query

  1. #1
    Join Date
    Feb 2012

    Unanswered: If in sql query

    i should start with telling you guys that i am newbie to the php+mysql world.

    I have spent some time trying to fix a mysql query with a if statement.

    $sql = "SELECT * FROM `booking` ORDER BY year DESC,month DESC,day DESC; ";

    what i would like is something like

    $sql = "SELECT IF (year>=''$TODAYS'YEAR,month>='$TODAYSMONTH',day>=' $TODAYSDATE') * FROM `booking` ORDER BY year DESC,month DESC,day DESC; ";

    the point with this is that i want to filter bookings that are old...

    is it possible?

    Thank You in Advance

  2. #2
    Join Date
    Apr 2002
    Toronto, Canada
    SELECT ...
      FROM booking
     WHERE CONCAT_WS( '-' , `year`,`month`,`day`) >= CURRENT_DATE
    please, take my advice, redesign your table to get rid of the three columns and replace them with a single DATE column | @rudydotca
    Buy my SitePoint book: Simply SQL

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts