Shakti Singh
Shakti Singh

Reputation: 86346

What is the problem with this mysql query

select count (*) from sales_order where date_format
(created_at,'%Y-%m-%d') >= 
'2009-11-02' and date_format(created_at,'%Y-%m-%d')
 <= '2010-12-08' and customer_id in 
(14,1113,1115,1117,1132,1312,1345);

it gave me this error

    ERROR 1064 (42000): 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 '*) from sales_order where 
date_format(created_at,'%Y-%m-%d') >= '2009-11-02' and' at line 1

Please let me know where is the problem

Upvotes: 1

Views: 102

Answers (2)

Dark Falcon
Dark Falcon

Reputation: 44181

The issue is with the space after COUNT. Do not use a space here. See this MySQL bug: Bug #2664 An extra space after Count in a Count(distinct... statement fails

Upvotes: 1

ajreal
ajreal

Reputation: 47321

No space allow for count (*)

count(*)

Upvotes: 3

Related Questions