select monthCount,count(*) as a from table1,table2 where left(date,7)=left(dateAndtime,7) group by monthCount

解决方案 »

  1.   

    报错
    [PortalDB] ERROR 1064: 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 '' at line 1
      

  2.   

    奇怪,我这边正常啊!能把建表的SQL贴上来吗?
      

  3.   

    我做了一个语句
    SELECT SUBSTRING(table1.accessDate,9,10),table1.accessCount,count(*) 
    from table2,table1 where SUBSTRING('2005-01-02',1,7) =  SUBSTRING(table2.visitDateAndTime,1,7)
    group by SUBSTRING(table1.accessDate,1,10)在上面那个表中SUBSTRING(table1.accessDate,9,10),我想得到单个月的日期,如2005-01就有31天
    2005-02只有28天,在上句中怎么改?