Skip to main content
Inspiring
October 12, 2008
Question

problem with mysql count with where clauese

  • October 12, 2008
  • 1 reply
  • 743 views
i think my query is wrong. can please someone guide me.

I am trying to get the countedvalue of myinbox table
but i am running into big trouble.

i tried searching the google but could not find the
relevant data.

please guide me

cheers

SELECT COUNT(sendTo) as sendtoCounted FROM
myinbox
GROUP BY sendTo
HAVING
read = <cfqueryparam cfsqltype="cf_sql_numeric"
value="1">
AND
recievedOn >= #DateAdd('d',-
7,DateFormat(now(),'mm/dd/yyyy'))#
This topic has been closed for replies.

1 reply

Prasanth_Kumar_S
Inspiring
October 12, 2008
Hi,
Please specify the error that you are getting. By looking at the query, it seems that changing the code
recievedOn >= #DateAdd('d',-7,DateFormat(now(),'mm/dd/yyyy'))#
to
recievedOn >= #CreateODBCDatetime(DateFormat(DateAdd('d',-7,now()),'mm/dd/yyyy')))#
should work.

-Prasanth
Inspiring
October 13, 2008
Hi correcting the query as suggested by you, following error occured..

Error Executing Database Query.
You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'read = 1 AND recievedOn >= '2008-10-06 00:00:00' GROUP BY se' at line 3
Prasanth_Kumar_S
Inspiring
October 13, 2008
Hi,
I just didn't notice the error with the HAVING clause. You cannot specify the fields in the HAVING clause. Try this code.