I've downloaded a source with a lot of code and tables, in one of the tables I got a column named "int" (The source is big and changing the column name isn't the solution for me).
Anyway, I can't print the data on my website because of the column name! Any other column in the table works except the column 'int'. It tells me this error:
You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'int FROM characters WHERE id = '30005'' at line 1]
"SELECT int FROM characters WHERE id = '" + userId + "'";
string selectIntSql = "SELECT COLUMN_NAME FROM INFORMATION_SCHEMA.COLUMNS
WHERE TABLE_SCHEMA = 'moopledev' AND TABLE_NAME = 'characters' AND ORDINAL_POSITION = 11";
string selectInt = SqlConnector.printData(selectIntSql);
"SELECT " + selectInt + " FROM characters WHERE id = '" + userId + "'";
SQL (any SQL) contains reserved words, which you better not use as a column name. INT is a very obvious one.
The way around this is:
Example for the backticks: