Database Administrators Stack Exchange is a question and answer site for database professionals who wish to improve their database skills and learn from others in the community. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I'm quite new on learning SQL and I seem to be running into an issue with the following code:

  `title` VARCHAR(50) NOT NULL,
  `url` VARCHAR(50) NOT NULL,
  PRIMARY KEY(`title`,`url`)

It's returning the following error:

#1064 - 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 'NOT NULL UNIQUE AUTO_INCREMENT, title VARCHAR(50) NOT NULL, url VARCHAR(50' at line 2

share|improve this question

closed as off-topic by StanleyJohns, Nick Chammas, dezso, RolandoMySQLDBA, Paul White Jul 8 '13 at 13:40

This question appears to be off-topic. The users who voted to close gave this specific reason:

  • "Too localized - this could be because your code has a typo, basic error, or is not relevant to most of our audience. Consider revising your question so that it appeals to a broader audience. As it stands, the question is unlikely to help other users (regarding typo questions, see this meta question for background)." – StanleyJohns, Nick Chammas, dezso, RolandoMySQLDBA, Paul White
If this question can be reworded to fit the rules in the help center, please edit the question.

I can't seem to answer my own question at this point but I figured it out. Adding INT after order solves it. – Chris Burton Jul 8 '13 at 3:33
Yes, that is correct. You hadn't defined a datatype for column order. And why have you accepted that answer? It doesn't explain what is wrong, it removes the UNIQUE constraint, it changes the PRIMARY KEY. Not very helpful. Do you know you can post an answer yourself? – ypercubeᵀᴹ Jul 8 '13 at 5:28
@ypercube Smart catch on the answer below. I ended up just using my own answer. However, I can't answer my own question as I don't have enough 'reputation' to do so. – Chris Burton Jul 8 '13 at 5:35
Oh yes, I think you need to have 15 reputation to do that or wait a few hours (or both, not sure.) – ypercubeᵀᴹ Jul 8 '13 at 5:40
@ypercube 10 rep points to answer or wait like 8 hours or something. I was able to get to 11 but now have to wait to accept my own answer. Thanks again. – Chris Burton Jul 8 '13 at 5:41

Try like below, it will help you...

  `title` VARCHAR(50) NOT NULL,
  `url` VARCHAR(50) NOT NULL,
  PRIMARY KEY(`order`)
share|improve this answer
Thank you. Is there a difference between INT and MEDIUMINT? – Chris Burton Jul 8 '13 at 4:09
Yes. It is. difference mainly on storage space. for more read have a look into – Praveen Prasannan Jul 8 '13 at 7:28
Why did you change the primary key definition? – dezso Jul 8 '13 at 12:56
up vote 0 down vote accepted
  `title` VARCHAR(255) NOT NULL,
  `url` VARCHAR(255) NOT NULL,
  PRIMARY KEY(`title`,`url`)

I was missing INT after order

share|improve this answer
Accept the answer by 'mark as answer' or upvote the answers which helped you. – Praveen Prasannan Jul 8 '13 at 7:38

Not the answer you're looking for? Browse other questions tagged or ask your own question.