Search code examples
mysqlsqlpopsql

Need help finding syntax error in SQL code


I have been trying to follow along with a SQL tutorial on YT. Every time I try to run this command, it gives me this error:

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 ')' at line 5

CREATE TABLE student (
student_id INT PRIMARY KEY,
name VARCHAR(20),
major VARCHAR(20),
);

INSERT INTO student VALUES (1, 'Jack', 'Biology');

Solution

  • try this

    drop table student;
    
    CREATE TABLE student (
      student_id INT PRIMARY KEY,
      name VARCHAR(20),
      major VARCHAR(20)
    );
    
    INSERT INTO student (student_id, name, major) VALUES (1, 'Jack', 'Biology');