Can someone tell me why this doesn't work?

create table download_warehouse
( avalonid int, downloads int, month int, year int )
SELECT avalonid, count(avalonid) downloads, month(stamp) month, year(stamp)
year
FROM avalon_downloads
group by avalonid, month, year;

The select statement works fine by itself. But I get a syntax error if I use
it with the create table statement. I know that the column names month and
year look suspicious. However, according to the docs, they are not
explicitly reserved in MySQL and should work fine.

I aliased the column names in the select statement for two reasons:
1. MySQL doesn't seem to allow group by with functions
   If I try "group by month(stamp)" etc. the SELECT query fails
2. If I understand the docs correctly, the column definitions need to match
   the column names in the select query if I want the data in the columns I 
   defined and not in new columns created from the SELECT statement. 

-Sean Hammon

---------------------------------------------------------------------
Before posting, please check:
   http://www.mysql.com/manual.php   (the manual)
   http://lists.mysql.com/           (the list archive)

To request this thread, e-mail <[EMAIL PROTECTED]>
To unsubscribe, e-mail <[EMAIL PROTECTED]>
Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php

Reply via email to