您应该在date列上使用from_unixtime()函数,该函数应包含1341241153之类的值.
因为这些值似乎以unix时间戳格式存储.
例:
mysql> select
-> from_unixtime( 1341241153 ) as 'my_datetime_1341241153',
-> date( from_unixtime( 1341241153 ) ) as 'my_date_1341241153',
-> curdate(),
-> curdate() > date( from_unixtime( 1341241153 ) ) 'is_today_later?',
-> curdate() = date( from_unixtime( 1341241153 ) ) 'is_today_equal?',
-> curdate() < date( from_unixtime( 1341241153 ) ) 'is_today_before?'
-> from
-> dual
-> \G
*************************** 1. row ***************************
my_datetime_1341241153: 2012-07-02 20:29:13
my_date_1341241153: 2012-07-02
curdate(): 2012-07-15
is_today_later?: 1
is_today_equal?: 0
is_today_before?: 0
1 row in set (0.00 sec)
您的查询应为:
SELECT a.name, COUNT(*) AS num FROM table2 b
INNER JOIN table1 a
ON ( b.status_id=a.id and curdate() = date( from_unixtime( b.crm_date_time_column ) ) )
GROUP BY status_id