Jump to content

MySQL Query Help Needed


ViperSBT

Recommended Posts

I have the following query:

SELECT r.club, MIN(r.besttime) as time, c.cname, t.date
FROM racing r
JOIN clubs c ON r.club = c.cnumber
INNER JOIN tournament t ON t.enumber = r.event && t.date >= '$limit' && r.besttime < 99.999
GROUP BY r.club 
HAVING DATEDIFF( MAX( date ) , MIN( t.date ) ) >4
ORDER BY time, c.cname

 

Which generates the following output:

club time cname date

83 0.000 BH 2005-07-08

146 0.000 MRRFB 2006-03-25

179 0.000 PS 2006-09-23

22 0.000 S 2005-04-30

2 14.963 TNG 2005-04-30

239 15.127 IR 2007-05-26

75 15.359 HF 2005-11-12

7 15.403 RD 2005-05-14

6 15.479 RDS 2005-05-14

 

The racing table has an entry for every event that a club has participated in.  I need the results to only show me clubs that have participated in more than one event and at least two of those events are more than 7 days apart from each other.

 

It seems like there should be a way to do this, but I am lucky I have gotten as far as I have... :)

Link to comment
https://forums.phpfreaks.com/topic/183606-mysql-query-help-needed/
Share on other sites

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.