1

// Please can anyone tell me what is wrong with this MySQL query syntax ?

String createTableSQL = ""
                + " CREATE TABLE location("
                + " location_id INTEGER PRIMARY KEY AUTOINCREMENT,"
                + " location_name VARCHAR(30),"
                + " addr VARCHAR(30),"
                + ")";

1 Answer 1

1

remove the last change AUTOINCREMENT in AUTO_INCREMENT and add PRIMARY KEY (location_id)

 String createTableSQL = ""
            + " CREATE TABLE location("
            + " location_id INTEGER PRIMARY KEY AUTO_INCREMENT,"
            + " location_name VARCHAR(30),"
            + " addr VARCHAR(30),"
            + " PRIMARY KEY (`location_id `))";
Sign up to request clarification or add additional context in comments.

2 Comments

I removed , maybe I have few mistakes so it didn't help at this time.
Great, thank you @Mike. It helped, table is created.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.