Jump to content


Photo

date_sub()


  • Please log in to reply
No replies to this topic

#1 AV1611

AV1611
  • Members
  • PipPipPip
  • Advanced Member
  • 997 posts

Posted 15 June 2006 - 05:20 PM

//edit figured it out, but will leave up if anyone cares:
// this was the problem line:
// AND DATE_SUB(NOW(),INTERVAL 30 DAY)<=surveyresults.DATE");
//forgot the surveyresults. part

neither of these will work...

$result1 = mysql_query("Select
count( distinct surveyresults.ID)
From
surveyresults
Inner Join survey ON surveyresults.ID = survey.ID
Where
survey.INACTIVE Not Like 'YES'
AND DATE_SUB(NOW(),INTERVAL 30 DAY)<=DATE");
if ($row = mysql_fetch_array($result1)){


$result2 = mysql_query("Select
surveyresults.TEAM_LEADER,
surveyresults.FNAME,
surveyresults.LNAME,
surveyresults.ID,
Avg(surveyresults.RATING) AS RATING
From
surveyresults
Inner Join survey ON surveyresults.ID = survey.ID
Where
survey.INACTIVE Not Like 'YES'
AND DATE_SUB(NOW(),INTERVAL 30 DAY)<=DATE
Group By
surveyresults.ID
ORDER BY
RATING desc");

here is my table structure:

# Table "surveyresults" DDL

CREATE TABLE `surveyresults` (
`TEAM_LEADER` varchar(255) NOT NULL default '',
`FNAME` varchar(255) NOT NULL default '',
`LNAME` varchar(255) NOT NULL default '',
`ID` varchar(255) NOT NULL default '',
`RATING` varchar(255) NOT NULL default '',
`EVALUATOR` varchar(255) NOT NULL default '',
`DATE` date NOT NULL default '0000-00-00',
`IP` varchar(255) NOT NULL default '',
`HOSTNAME` varchar(255) NOT NULL default '',
`REMARKS` text NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=latin1 COMMENT='InnoDB free: 13312 kB; InnoDB free: 13312 kB; InnoDB free: 1'




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users