December 9th, 2012, 11:11 AM
Honestly, I have no idea what I am doing wrong here..
This is my query:
INSERT INTO 'categories' ('id', 'name') VALUES
This is the error I am getting:
#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 ''categories' ('id', 'name') VALUES (1, 'Official'), (2, 'Game'), (3, 'Support'),' at line 1
Here is some more information on the fields and such:
Any help is greatly appreciated!
# Column Type Collation Attributes Null Default Extra
1 id int(100) UNSIGNED No None AUTO_INCREMENT
2 name varchar(100) latin1_swedish_ci No None
December 9th, 2012, 11:32 AM
Firstly: you posted in the wrong forum. This is for Microsoft SQL Server which is a completely different thing than MySQL (which you are using).
Secondly: you are using single quotes for identifiers, which is wrong. Single quotes are only used for character literals (aka strings). Not for anything else. Identifiers (table names, column names, ...) do not need any quotes.
So you need to use:
You might see some MySQL statements using those dreaded non-standard backticks for identifiers (`categories`). They are only needed if your identifier is a reserved word or contains special characters (such as spaces). If you find yourself in a position where you need a quoted identifier, it's better to use the standard quoting style using double quotes ("categories"). Or even better: use a different name.
INSERT INTO categories (id, name) VALUES
I will not read nor answer questions where the SQL code is messy and not formatted properly using [code] tags.
Tips on how to ask better questions:
December 9th, 2012, 11:48 AM
Alright well thanks for the reply. Sorry about posting in the wrong forum.
Originally Posted by shammat
December 9th, 2012, 03:44 PM
yet another developer pwned by mysql's backticks
Originally Posted by braskez
you probably saw the backticks in somebody else's code and thought they were quotes
they're actually backticks
but you shouldn't be using them anyway, because they are only required if your table or column name contains a special character or is a reserved word, and you shouldn't allow those types of names
thread moved to mysql forum