Search code examples
mariadbcommentsmysql-error-1064

Unrecognized statement type. (near "User" at position 4)


Static analysis:

1 errors were found during analysis.

Unrecognized statement type. (near "User" at position 4) SQL query:

----User Table Create---- CREATE TABLE User_( u_ID char(5) NOT NULL, u_NIC char(12) NOT NULL, u_f_name varchar(50), u_l_name varchar(50), u_email varchar(50), u_address varchar(255), u_dob date, u_role varchar(20), constraint user_PK primary key(u_ID), constraint Uu_IDChk check(u_ID like '[u/U][0-9][0-9][0-9][0-9]'), )

MySQL said: Documentation

#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 '----User Table Create---- CREATE TABLE User_( u_ID char(5) NOT NULL, u_NIC ' at line 1

I'm getting this error while importing the database to phpmyadmin. How to fix this issue?

Code:

----User Table Create----
CREATE TABLE User_(
    u_ID char(5) NOT NULL,
    u_NIC char(12) NOT NULL,
    u_f_name varchar(50),
    u_l_name varchar(50),
    u_email varchar(50),
    u_address varchar(255),
    u_dob date,
    u_role varchar(20),

    constraint user_PK primary key(u_ID),
    constraint Uu_IDChk check(u_ID like '[u/U][0-9][0-9][0-9][0-9]'),
);

Solution

  • MariaDB comment syntax requires a space after the initial -- characters. It's a syntax error if you omit the space.

    WRONG:

    ----User Table Create----
    

    RIGHT:

    -- User Table Create --