-1

When trying to create a table in SQL it gives me a syntax error, and I'm not sure what is the problem, since it's a very simple table

I tried this...

CREATE TABLE happy (
    rank INT,
    swag VARCHAR(20)
);

which is the typical syntax to create a table

I tried to remove primary key, but I was getting the same thing.

Mark Rotteveel
  • 100,966
  • 191
  • 140
  • 197
Bhavya
  • 7
  • 1
  • 1
    As per the [ask], please [**do not** post images of code, data, error message, etc](https://meta.stackoverflow.com/questions/285551). Instead, copy or type the text into your question, [formatted as code](https://meta.stackoverflow.com/questions/251361#251362). Reserve the use of images for diagrams or demonstrating rendering bugs; things that are impossible to describe accurately via text. Also, show the exact error you are getting. – Bohemian Jan 06 '23 at 16:32
  • 2
    Duplicate of https://stackoverflow.com/questions/23446377/syntax-error-due-to-using-a-reserved-word-as-a-table-or-column-name-in-mysql/ – Bill Karwin Jan 06 '23 at 16:42

1 Answers1

2

The rank is a MySQL reserved word defined in MySQL version 8.0.

Try some other column name than rank

mr.loop
  • 818
  • 6
  • 20