Sql

niahossain

New Member
Messages
16
Reaction score
0
Points
0
I went to phpmyadmin, and clicked on the SQL quary link on the upper left corner. in the quary box, i typed in the following to create a table :

Code:
Create table Products {
Product id bigint(20) NOT NULL auto_increment,
Name varchar(40) NOT NULL default '',
Shop varchar(100) NOT NULL default '',
Price varchar(20) NOT NULL default '',
Category varchar(20) NOT NULL default '',
PRIMARY KEY (Productid)
);

And i got the following error message :

Code:
 <H1>Error[/B]

SQL query: 
CREATE TABLE Products{Product id bigint( 20 ) NOT NULL AUTO_INCREMENT ,
Name varchar( 40 ) NOT NULL default '',
Shop varchar( 100 ) NOT NULL default '',
Price varchar( 20 ) NOT NULL default '',
Category varchar( 20 ) NOT NULL default '',
PRIMARY KEY ( Productid ) 

) 

 
MySQL said:  
#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 '{
Product id bigint(20) NOT NULL auto_increment,
Name varchar(40) NOT NULL def' at line 1
</H1>
what should i do ? i am new at this, and i want to create a search option for my database, but i'm not even being able to create a table. Please help !
 

rickle42

New Member
Messages
59
Reaction score
0
Points
0
Just on a quick look I noticed the problem i think....
You start with { and end with ). needs to be either () or {}.
Edit:
Also Productid has a space when it is declared then no space when calling it a primary id. I dont know if its ok to have a space in mysql field names.
Product id ----- Looks funny to me. You could do Product_id or Productid.
 
Last edited:

jsobeck

New Member
Messages
479
Reaction score
0
Points
0
I would suggest using phpmyadmin's form for creating a new table, I would think it should simplify things.
 
Top