Reputation: 49
I'm getting a syntax error on a create table string. I've had a look online to see if there's anything I'm missing but I can't spot what's wrong.
//SQL Statement to create table on phpmyadmin if not exists
String createTable = "CREATE TABLE IF NOT EXISTS user(\n"
+ "id INT NOT NULL AUTO INCREMENT \n"
+ "username VARCHAR(20) NOT NULL \n"
+ "realname VARCHAR(100) NOT NULL \n"
+ "password VARCHAR(100) NOT NULL \n"
+ "email VARCHAR(100) NOT NULL \n"
+ "gym VARCHAR(100) \n"
+ "belt VARCHAR(100) \n"
+ "dateofbirth DATE NOT NULL \n"
+ "profilepic LONGBLOB \n"
+ "biography VARCHAR(1000) \n"
+ "motto VARCHAR(200) \n"
+ "PRIMARY KEY (id)\n"
+ ")";
Output says;
"near 'AUTO INCREMENT
username VARCHAR(20) NOT NULL
realname VARCHAR(100) NOT NULL
p' at line 2"
Upvotes: 0
Views: 68
Reputation: 164089
Drop all \n
and replace with ,
after each column except for the last.
Also for MySql it's AUTO_INCREMENT
, not AUTO INCREMENT
.
Upvotes: 1