Jump to content

Selecting between dates using a join


OutOfInk

Recommended Posts

Am i better off using a join or between statement and if possible please leave an example.

 

I want to retrieve the current 'round' from my database.  To do this i need to compare the current date and time to the 'gameround' table 'Date' and 'Time'.

 

This is an example of the database im trying to work which round it is;

 

CellID Round Home HODDS Away AODDS Ground Date Time status won lost
1 1 Collingwood 2.40 Fremantle 1.70 Etihad 2014-03-14 19:50:00 Lock None None
2 1 GWS Giants 15 Sydney 1.00 Skoda 2014-03-15 16:40:00 Lock None None
3 1 Gold Coast 2.50 Richmond 1.60 Metricon 2014-03-15 18:40:00 Lock None None

 

Thanks

Link to comment
https://forums.phpfreaks.com/topic/287272-selecting-between-dates-using-a-join/
Share on other sites

when you copy/paste the content from your database gui, it copies the links and image tags leading to your web hosting, which causes a pop-up authentication dialog box every time someone views your post. in the future, just copy/paste the necessary text.

the following will select the current Round number, if any. if you want to select the rows corresponding to that round number, you would use this as a sub-query in your main query -

SELECT Round, MIN(CONCAT(Date,' ',Time)) as start, MAX(CONCAT(Date,' ',Time)) as end FROM gameround GROUP BY Round HAVING NOW() BETWEEN start AND end

 

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.