Luke Foster Luke Foster - 7 months ago 38
SQL Question

mysql 1064 error SYNTAX ERROR

I keep getting this error every time i try to create a table in my sql database:

Error in query (1064): Syntax error near 'CREATE TABLE IF NOT EXISTS

users
(
id
int(10) NOT NULL AUTO_INCREMENT, `' at line 2

Could I get some help with this?

use luke_f_db
CREATE TABLE IF NOT EXISTS `users` (
`id` int(10) NOT NULL AUTO_INCREMENT,
`username` varchar(50) NOT NULL,
`email` varchar(50) NOT NULL,
`password` varchar(50) NOT NULL,
`trn_date` datetime NOT NULL,
PRIMARY KEY (`id`)
);

Answer

There's an error with your use command. Add an ; behind the first line or just check if the database exists and your account has access to it.

The CREATE Code worked fine for me.

Comments