Joshua Nguyen Joshua Nguyen - 1 month ago 12
MySQL Question

SQL #1064 while using myphpadmin

So I wrote up some SQL statements and as I went to test them I was greeted with the following error. Why it's rejecting this?

CREATE TABLE Student
(stud_id INT unsigned NOT NULL,
stud_name VARCHAR NOT NULL,
stud_phone INT(10) unsigned NOT NULL,
stud_date_of_birth DATE NOT NULL,
stud_city VARCHAR NOT NULL,
stud_address VARCHAR NOT NULL,
stud_postcode INT(4) unsigned NOT NULL,
PRIMARY KEY (stud_id, stud_phone)
);



#1064 - You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'NOT NULL,
stud_phone INT(10) unsigned NOT NULL,
stud_date_of_birth DATE NOT ' at line 3

Answer Source

You have to specify the length to the VARCHAR datatype like VARCHAR(100). This is the only thing with your query.

Your modified query looks like as below.

CREATE TABLE Student 
(stud_id INT unsigned NOT NULL, 
stud_name VARCHAR(100) NOT NULL, 
stud_phone INT(10) unsigned NOT NULL, 
stud_date_of_birth DATE NOT NULL,
stud_city VARCHAR(100) NOT NULL,
stud_address VARCHAR(100) NOT NULL,
stud_postcode INT(4) unsigned NOT NULL,
PRIMARY KEY (stud_id, stud_phone)
);

After correction this if the error still showing in you phpMyadmin then you have to remove Delimiter from the Delimiter textbox in your phpmyadmin place at the bottom of you query filed.

enter image description here