Reputation: 534
I am having a coulmn name called "condition name" (.sql file has been generated from server)
But in android I am getting following exception while reading data from that table.
12-24 14:34:00.870: W/System.err(269): android.database.sqlite.SQLiteException: no such column: condition: ,
while compiling:
SELECT condition, category, subcategory,condition name, local path, remote path, title, content_type FROM library WHERE category = ?
Its not recognizing whole table name and breaking at space. if you have any ideas please assist me.
Upvotes: 16
Views: 32415
Reputation: 973
And you put the table name outside the quote as in:
tableName."column name"
and not
"tableName.column name"
Upvotes: 7
Reputation: 180070
For quoting identifiers like table/column names, SQLite supports back ticks for compatibility with MySQL, and square brackets for compatibility with SQL Server, but the portable way is to use double quotes:
SELECT "condition name" FROM library
(Single quotes would be used for string values.)
Upvotes: 31
Reputation: 126465
Use single quotes
SELECT 'condition name' FROM library
or double quotes
SELECT "condition name" FROM library
in some cases the name of the table can contain space and even aphostrope, like:
SELECT condition's name FROM library
in this case replace '
with ''
in the name of the table:
SELECT 'condition''s' name FROM library
Upvotes: 1