Click to See Complete Forum and Search --> : simple decimal problem


crazycoder
03-11-2006, 06:22 PM
I have this code to create the database:

drop database expenses2006;
create database expenses2006;
use expenses2006;
create table January ( <-- line 5
id int not null auto_increment,
Date varchar(5),
Description varchar(50),
Office Exp. decimal(),
Dues/Public decimal(),
Business Lunch decimal(),
Conf./Cont. ED. decimal(),
Supplies for Prod. decimal(),
Small Equip. decimal(),
Prom./Adv. decimal(),
Travel decimal(),
Freight decimal(),
Photo decimal(),
Post decimal(),
primary key(id)
);

I have it make an identical table for every month of the year. It gives me messages saying something is wrong with the 'decimal' in line five. I have tried decimal, decimal(3,2), and as you can see decimal().

NogDog
03-11-2006, 09:25 PM
I've never worked with a database system that allowed column names with slashes, space, or periods. Could that be the problem?

crazycoder
03-11-2006, 09:37 PM
I thought that might be the problem, but the errors from the console point elsewhere. I'll try it though.

NogDog
03-11-2006, 10:14 PM
Error messages are notorious for being misleading. :)

chazzy
03-11-2006, 11:41 PM
you have the following errors in your create table:

error: column names can't contain spaces
warning: invalid character ("/")
warning: invalid character (".")
error: invalid column type decimal().

decimal needs at least 1 argument, it seems.
http://dev.mysql.com/doc/refman/5.0/en/numeric-types.html

crazycoder
03-12-2006, 09:09 AM
Thanks! I just replaced all the ' ' with underscores.