0

I am trying to create a table in a database, I am using mysql 5.5 (im using myphpadmin in MAMP) below is my table, I have been using the mysql manual and it seems like everything here is as it should be? but i keep getting 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 ''users'( 'id' int UNSIGNED NOT NULL auto_increment PRIMARY KEY, 'username' VAR' at line 1

CREATE TABLE 'users'(
 'id' int UNSIGNED NOT NULL auto_increment PRIMARY KEY,
 'username' VARCHAR(16) NOT NULL, 
 'password' VARCHAR(16) NOT NULL,
 'name'VARCHAR(35) NOT NULL,
 'entry'text NOT NULL,
 'date_created' timestamp NOT NULL DEFAULT NOW(),
  key('username')
  );
4

1 に答える 1

2

一重引用符の代わりにバッククォートを使用する必要があります。

CREATE TABLE `users`(
 `id` int UNSIGNED NOT NULL auto_increment PRIMARY KEY,
 `username` VARCHAR(16) NOT NULL, 
 `password` VARCHAR(16) NOT NULL,
 `name` VARCHAR(35) NOT NULL,
 `entry` text NOT NULL,
 `date_created` timestamp NOT NULL DEFAULT NOW(),
  key(`username`)
  );

SQL FiddlewithDemoを参照してください。

注:またはバックティックをまったく使用しないでください。

CREATE TABLE users(
 id int UNSIGNED NOT NULL auto_increment PRIMARY KEY,
 username VARCHAR(16) NOT NULL, 
 password VARCHAR(16) NOT NULL,
 name VARCHAR(35) NOT NULL,
 entry text NOT NULL,
 date_created timestamp NOT NULL DEFAULT NOW(),
  key(username)
  );

SQL FiddlewithDemoを参照してください

于 2013-01-25T20:27:53.177 に答える