Single quotes should only be used in values. Therefore they are ok in VALUES ('blabla')
. Already in table names, columns and aliases , either you do not use anything, or use the backticks '
. These backticks are only required if the name of your table, column, or alias matches some reserved term in MySQL. So in your second query, this part:
INSERT INTO '_user' ('firstname')
has syntax errors. The simplest correct query would look like this (already in a string):
"INSERT INTO _user (firstname) VALUES ('blabla')"
Example of use that the backtick requires, if you had an INT type column named "order" (which is reserved word):
"INSERT INTO _user (firstname, 'order') VALUES ('blabla', 1)"
It's easy to remember that it's always good to avoid using reserved words such as database name, table, column, alias, index, function, procedure, etc.