This struck me by surprise when using sqlite3: when a value in the
field is the same as the field name, queries may not work as expected
if double quotes are used instead of single quotes.
For example:
$ sqlite3 sample.db .dump
BEGIN TRANSACTION;
CREATE TABLE seq (a);
INSERT INTO "seq" VALUES('1');
INSERT INTO "seq" VALUES('2');
INSERT INTO "seq" VALUES('3');
INSERT INTO "seq" VALUES('a');
COMMIT;
$ sqlite3 -header -column sample.db 'select * from seq where a="1" ; '
a
----------
1
$ sqlite3 -header -column sample.db 'select * from seq where a="a" ; '
a
----------
1
2
3
a
$ sqlite3 -header -column sample.db "select * from seq where a='a' ; "
a
----------
a
$ sqlite3 -header -column sample.db
SQLite version 3.4.2
Enter ".help" for instructions
sqlite> select * from seq where a="a" ;
a
----------
1
2
3
a
Notice the difference when single versus double quotes are used and
the field name is one of the values.
Regards,
- Robert
--~--~---------~--~----~------------~-------~--~----~
Central West End Linux Users Group (via Google Groups)
Main page: http://www.cwelug.org
To post: [email protected]
To subscribe: [EMAIL PROTECTED]
To unsubscribe: [EMAIL PROTECTED]
More options: http://groups.google.com/group/cwelug
-~----------~----~----~----~------~----~------~--~---