SQL Query error
Posted by: hektor39 (---.surfsnel.dsl.internl.net)
Date: July 09, 2010 02:43PM

Hello i am a newby with wampserver.

I try to create a table but i get an error:


SQL-query:

CREATE TABLE 'adreskaart'(
'id'TINYINT( 4 ) NOT NULL AUTO_INCREMENT ,
'naam'VARCHAR( 50 ) DEFAULT NULL ,
'adres'VARCHAR( 50 ) DEFAULT NULL ,
'postcode'VARCHAR( 6 ) DEFAULT NULL ,
'plaats'VARCHAR( 50 ) DEFAULT NULL ,
'telefoon'VARCHAR( 10 ) DEFAULT NULL ,
PRIMARY KEY ( 'id' ) ,
UNIQUE KEY 'id'( 'id' )
);

MySQL retourneerde: Documentatie
#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 ''adreskaart' (
'id' TINYINT(4) NOT NULL AUTO_INCREMENT,
'naam' VARCHAR(50)' at line 1


I hope someone can help me solve this problem.

Re: SQL Query error
Posted by: c2dan (---.15-1.cable.virginmedia.com)
Date: July 09, 2010 07:28PM

Table/field names should not be wrapped in quotes ( eg: ' ).

When quoting table/field names you should use back-ticks ( eg: ` ).

Quotes should only be used around values, for example when inserting data into the database
INSERT INTO `table_name` SET `field1` = 'some value';

Or grabbing data from the database, eg
SELECT `some_field` FROM `table_name` WHERE `id` = 'some value';

Hope you understand where to use quotes and backticks. Do note thought that backt-ticks are optional.

Re: SQL Query error
Posted by: hektor39 (---.surfsnel.dsl.internl.net)
Date: July 09, 2010 09:54PM

Thank you!!

I have changed all the quotes into backsticks. Now it's working good.

Sorry, only registered users may post in this forum.