Home  >  Q&A  >  body text

When creating the SQL table, a 1064 error was encountered on line 6

<p><pre class="brush:php;toolbar:false;">CREATE TABLE Customer( customer_id INT AUTO_INCREMENT PRIMARY KEY, customer_name VARCHAR(50) NOT NULL, customer_email VARCHAR(100) NULL, street_address VARCHAR(50) NULL, city ​​VARCHAR(50) NULL, province CHAR(2) NULL, postal_code CHAR(6) NULL, );</pre> <p>As mentioned above, when trying to create a new table, I encountered error 1064 and am not sure why. The name "city" is not a reserved word, and as far as I know the definition is not outdated. </p> <p><strong>#1064 - Your SQL syntax is incorrect; check the manual for your MySQL server version for the correct syntax to use near the ")" on line 6</strong>< /p>
P粉875565683P粉875565683421 days ago359

reply all(2)I'll reply

  • P粉818125805

    P粉8181258052023-08-27 00:06:03

    can you try this

    CREATE TABLE Customer(
        customer_id INT AUTO_INCREMENT PRIMARY KEY,
        customer_name VARCHAR(50) NOT NULL,
        customer_email VARCHAR(100) NULL,
        street_address VARCHAR(50) NULL,
        city VARCHAR(50) NULL,
        province CHAR(2) NULL,
        postal_code CHAR(6) NULL
    );

    reply
    0
  • P粉952365143

    P粉9523651432023-08-27 00:01:05

    Remove the comma after postal_code

    CREATE TABLE Customer(
    customer_id INT AUTO_INCREMENT PRIMARY KEY,
    customer_name VARCHAR(50) NOT NULL,
    customer_email VARCHAR(100) NULL,
    street_address VARCHAR(50) NULL,
    city VARCHAR(50) NULL,
    province CHAR(2) NULL,
    postal_code CHAR(6) NULL
    );

    reply
    0
  • Cancelreply