Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

CREATE TABLE SQL statement won't run

Tags:

php

mysql

When I try to run this statement:

CREATE TABLE 'score_table' 
(
  'name' text NOT NULL, 
  'email' text NOT NULL, 
  'company' text NOT NULL, 
  'score_total' bigint(11) NOT NULL, 
  'score_string' longtext NOT NULL, 
  'id' int(11) NOT NULL auto_increment, 
  'date' timestamp NOT NULL default CURRENT_TIMESTAMP on update CURRENT_TIMESTAMP,
  PRIMARY KEY  ('id') 
) 
ENGINE=MYISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=0 ;

I get this error:

#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 ''score_table' 
('name' text NOT NULL, 'email' text NOT NULL, 'company' text NOT N' at line 1

And I have no idea what's wrong, any help would be greatly appreciated!

like image 497
bbeckford Avatar asked Jun 29 '26 03:06

bbeckford


1 Answers

Table and field names need to be put in backticks instead of single quotes (or no quotes at all):

CREATE TABLE `score_table`.....
like image 196
Pekka Avatar answered Jul 01 '26 16:07

Pekka



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!