If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Database Server Software > MySQL > If in sql query

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 02-01-12, 17:43
Karstensson Karstensson is offline
Registered User
 
Join Date: Feb 2012
Posts: 1
If in sql query

Hi!
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
Reply With Quote
  #2 (permalink)  
Old 02-02-12, 00:18
r937 r937 is offline
SQL Consultant
 
Join Date: Apr 2002
Location: Toronto, Canada
Posts: 19,525
Code:
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
__________________
r937.com | rudy.ca
please visit Simply SQL and buy my book
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On