SQLite Forum

INNER JOIN error
Login
The SQL standard is to use double quotes for wrapping names that are keywords used as names or contain spaces.

SQLite uses " and ' interchangeably (almost).

The alternate use of square brackets for wrapping keywords used as names or names that contain spaces. The ODBC driver I am using, namely, http://www.ch-werner.de/sqliteodbc/sqliteodbc.exe does also allow square brackets BUT the CLI doesn't.

Received wisdom also suggests that SQL keywords be capitalised. Neither the CLI nor the ODBC driver enforce this.

My session:

sqlite> drop table if exists tbl;
sqlite> create temp table tbl (myName);
sqlite> insert into tbl values("myName"); -- double quotes for literal
sqlite> select "myName" from tbl; -- double quotes for column name
myName
------
myName
sqlite> select "myname"; -- double quotes for literal
"myname"
--------
myname

sqlite> /* Alternatively  ... less ambiguity? */

sqlite> select "myname"; -- double quotes for literal ... RETURNS quotes in column name
"myname"
--------
myname
sqlite> select [myName] from tbl; -- square brackets for column name
myName
------
myName
sqlite> select 'myname'; -- double quotes for literal -- NOW single quotes uotes in column name
'myname'
--------
myname


I note your point about the SQL standard but 
- SQLite is also using single quotes to wrap column names (not the SQL standard)
- the use of square brackets does enhance readability, I think.

PS. Should .echo on ignote /* block comments */