Solved

mysql syntax error

Posted on 2009-06-28
5
219 Views
Last Modified: 2012-05-07
Why it is not working?

#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 'default int(1) default '0' not null , PRIMARY KEY (products_attributes_id) )' at line 10

create table products_attributes (
  products_attributes_id int(11) not null auto_increment,
  products_id int(11) default '0' not null ,
  options_id int(11) default '0' not null ,
  options_values_id int(11) default '0' not null ,
  options_values_price decimal(15,4) default '0.0000' not null ,
  price_prefix char(1) not null ,
  model varchar(64) not null ,
  products_attributes_thumbnail varchar(64) not null ,
  default int(1) default '0' not null ,
  PRIMARY KEY (products_attributes_id)
);

Open in new window

0
Comment
Question by:jack_
  • 2
  • 2
5 Comments
 
LVL 57

Expert Comment

by:Raja Jegan R
ID: 24730877
Try this one out:
create table products_attributes (
  products_attributes_id int not null auto_increment PRIMARY KEY,
  products_id int(11) default '0' not null ,
  options_id int(11) default '0' not null ,
  options_values_id int(11) default '0' not null ,
  options_values_price decimal(15,4) default '0.0000' not null ,
  price_prefix char(1) not null ,
  model varchar(64) not null ,
  products_attributes_thumbnail varchar(64) not null ,
  default int(1) default '0' not null
);

Open in new window

0
 
LVL 57

Expert Comment

by:Raja Jegan R
ID: 24730886
Ignore the one above:
create table products_attributes (
  products_attributes_id int(11) not null auto_increment PRIMARY KEY,
  products_id int(11) default '0' not null ,
  options_id int(11) default '0' not null ,
  options_values_id int(11) default '0' not null ,
  options_values_price decimal(15,4) default '0.0000' not null ,
  price_prefix char(1) not null ,
  model varchar(64) not null ,
  products_attributes_thumbnail varchar(64) not null ,
  default int(1) default '0' not null
);

Open in new window

0
 
LVL 28

Accepted Solution

by:
gamebits earned 500 total points
ID: 24730889
default is a reserved word, enclose it between backtick`

`default` int(1) default '0' not null ,
0
 
LVL 3

Author Comment

by:jack_
ID: 24730929
Great thanks gamebits
0
 
LVL 28

Expert Comment

by:gamebits
ID: 24730976
Thanks for the points and grade.
0

Featured Post

3 Use Cases for Connected Systems

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, testing some more, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Foreword In the years since this article was written, numerous hacking attacks have targeted password-protected web sites.  The storage of client passwords has become a subject of much discussion, some of it useful and some of it misguided.  Of cou…
PL/SQL can be a very powerful tool for working directly with database tables. Being able to loop will allow you to perform more complex operations, but can be a little tricky to write correctly. This article will provide examples of basic loops alon…
This video shows how to use Hyena, from SystemTools Software, to bulk import 100 user accounts from an external text file. View in 1080p for best video quality.

777 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question