這是我在的index.php代碼:的MySQL如何設置USERNAME字段應指定爲唯一
$sql = "CREATE TABLE 6470exerciseusers (
USERNAME VARCHAR(100),
'PASSWORD_HASH' CHAR(40),
PHONE VARCHAR(10),
UNIQUE (USERNAME)
)";
,這是錯誤:
Error creating table: 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 ''PASSWORD_HASH' CHAR(40), PHONE VARCHAR(10), UNIQUE (USERNAME))' at line 3
在MySQL中,你將不得不看是這樣的: 'ADD UNIQUE INDEX'USERNAME_UNIQUE'('USERNAME' ASC)' –