On Wed, Apr 3, 2013 at 1:54 AM, Support <apps...@gmail.com> wrote: > Hi > I have a database which has an entry "USE" in a table called airports with > column LocationID. > When I call > sqlite3 -line ~/Desktop/maps.db 'select * from airports where LocationID > like "USE%";' > I get correct result. > > But when I call > sqlite3 -line ~/Desktop/maps.db 'select * from airports where > LocationID=="USE";' > > I do not get any result. >
As you can see below, it works if you put double-quotes around the statement. Works on Linux too. By wrapping the statement in single-quotes, and attempting to "escape" the single-quotes around USE by doubling them, you are in effect closing the previous single-quote, and opening a new one, but no single-quote is left for SQLite to process. It's as if you wrote where locid = USE, and SQLite errors out with "Error: no such column: USE". So I think it's a shell-specific quote escaping issue. C:\Users\DDevienne>sqlite3 foo.db SQLite version 3.7.15.2 2013-01-09 11:53:05 Enter ".help" for instructions Enter SQL statements terminated with a ";" sqlite> create table airports (locid text primary key); sqlite> insert into airports values ('USE'), ('IAH'); sqlite> .q C:\Users\DDevienne>sqlite3 -line foo.db "select * from airports where locid like 'USE%';" locid = USE C:\Users\DDevienne>sqlite3 -line foo.db "select * from airports where locid = 'USE';" locid = USE C:\Users\DDevienne>sqlite3 -line foo.db "select * from airports where locid == 'USE';" locid = USE > When I call > sqlite3 -line ~/Desktop/maps.db 'select LocationID from airports;' > > I do see that "USE" is in there among many other entries. > > It only happens with "USE". Does not happen with "BOS" etc > Frankly, that's surprising. If that's true, you need to "show us the data". Perhaps there's invisible whitespace after USE that like 'USE%' accepts, whereas = 'USE' does not. --DD _______________________________________________ sqlite-users mailing list sqlite-users@sqlite.org http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users