Solved

mysql syntax error

Posted on 2009-06-28
5
223 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

VMware Disaster Recovery and Data Protection

In this expert guide, you’ll learn about the components of a Modern Data Center. You will use cases for the value-added capabilities of Veeam®, including combining backup and replication for VMware disaster recovery and using replication for data center migration.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Complex SQL statement in VB.NET 7 31
IIF in access query 19 27
Using Modal's in to Retrieve Data from MySql and Populate Forms 13 42
SQL Recursion schedule 13 19
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…
Load balancing is the method of dividing the total amount of work performed by one computer between two or more computers. Its aim is to get more work done in the same amount of time, ensuring that all the users get served faster.
Although Jacob Bernoulli (1654-1705) has been credited as the creator of "Binomial Distribution Table", Gottfried Leibniz (1646-1716) did his dissertation on the subject in 1666; Leibniz you may recall is the co-inventor of "Calculus" and beat Isaac…
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…

830 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