in reply to Re: Managing Inventory Sections with Perl and SQL
in thread Managing Inventory Sections with Perl and SQL

Hi, here's what I've got so far:

create table section ( section_id int(9) unsigned not null, section_name varchar(32), created datetime default '0000-00-00 00:00:00' not null, primary key (section_id) ); create table inventory_items ( item_id int(9) unsigned not null auto_increment, section_id int(9) unsigned, item_name varchar(32) not null, description varchar(255), photo_name varchar(255), created datetime default '0000-00-00 00:00:00' not null, modified datetime default '0000-00-00 00:00:00' not null, primary key (item_id), ); create table item_price ( item_id int(9) unsigned not null auto_increment, price decimal(11, 2), sale_price decimal(11, 2), valid_from datetime not null, valid_to datetime not null, primary key (item_id), );

I'm currently receiving an error "ERROR 1064 at line 8: You have an error in your SQL syntax near ')' at line 10." I'm running this from a file like so: mysql inventory < inventory.sql -u username -p I was receiving an error that said the same but at line 6 before, I removed the comma after primary key and it seemed to change the error - could this have something to do with whitespace/comma placement? I noticed in your example you placed the preceeding line's comma before the next statement.

Thanks! :)

Replies are listed 'Best First'.
Re: Re: Re: Managing Inventory Sections with Perl and SQL
by mpeppler (Vicar) on Jul 30, 2003 at 06:25 UTC
    The placements of the commas in my example are just habit - that should not be an issue.

    However I don't really know MySQL, so off-hand I don't see where the syntax error could be. Personally I'd split this out to create each table separately, and that might make it a little easier to find the problem.

    In addition I think that you have a slight logic or design problem: Your "item_price" table has primary key "item_id" - which means that you can only have one row in that table for any item, which also means that you can't keep a price history - maybe you don't need it at this point, but I thought I'd point it out.

    Michael