Re: [sqlite] Odd results return by SELECT query WHERE word = "word"
'word' is correct SQL, "word" is not. Matteo Vescovi wrote: Hi, I am getting weird results when executing a query that has this WHERE clause: WHERE word = "word". The query works fine if I use WHERE word = 'word'. The following illustrates the problem: [EMAIL PROTECTED]:~$ sqlite -version 2.8.17 [EMAIL PROTECTED]:~$ cat populate.sql CREATE TABLE _1_gram (word TEXT, count INTEGER, UNIQUE(word) ); INSERT INTO _1_gram VALUES("foo", 13); INSERT INTO _1_gram VALUES("bar", 16); INSERT INTO _1_gram VALUES("word", 36); INSERT INTO _1_gram VALUES("foobar", 336); [EMAIL PROTECTED]:~$ sqlite test.db < populate.sql [EMAIL PROTECTED]:~$ sqlite test.db SQLite version 2.8.17 Enter ".help" for instructions sqlite> SELECT * FROM _1_gram WHERE word = 'word'; word|36 sqlite> SELECT * FROM _1_gram WHERE word = "word"; foo|13 bar|16 word|36 foobar|336 sqlite> .quit [EMAIL PROTECTED]:~$ Am I missing something here (I haven't used SQL in a while...), or is this a bug? Cheers, - Matteo Vescovi ___ All New Yahoo! Mail – Tired of unwanted email come-ons? Let our SpamGuard protect you. http://uk.docs.yahoo.com/nowyoucan.html - To unsubscribe, send email to [EMAIL PROTECTED] - - To unsubscribe, send email to [EMAIL PROTECTED] -
Re: [sqlite] Odd results return by SELECT query WHERE word = "word"
--- Tomash Brechko <[EMAIL PROTECTED]> wrote: > On Fri, May 11, 2007 at 09:57:01 +0100, Matteo > Vescovi wrote: > > Hi, > > I am getting weird results when executing a query > that > > has this WHERE clause: WHERE word = "word". > > > > The query works fine if I use WHERE word = 'word'. > > The WHERE word = "word" is a no-op. From "SQLite > Keywords" section of > http://www.sqlite.org/lang.html: > > 'keyword' A keyword in single quotes is > interpreted as a literal > string if it occurs in a context where a > string literal is > allowed, otherwise it is understood as > an identifier. > > "keyword" A keyword in double-quotes is > interpreted as an identifier > if it matches a known identifier. > Otherwise it is > interpreted as a string literal. > That explains it. I was missing something, after all. Thanks for pointing me to the documentation and sorry for the noise. - Matteo > > -- >Tomash Brechko > > - > To unsubscribe, send email to > [EMAIL PROTECTED] > - > > ___ Yahoo! Mail is the world's favourite email. Don't settle for less, sign up for your free account today http://uk.rd.yahoo.com/evt=44106/*http://uk.docs.yahoo.com/mail/winter07.html - To unsubscribe, send email to [EMAIL PROTECTED] -
Re: [sqlite] Odd results return by SELECT query WHERE word = "word"
On Fri, May 11, 2007 at 09:57:01 +0100, Matteo Vescovi wrote: > Hi, > I am getting weird results when executing a query that > has this WHERE clause: WHERE word = "word". > > The query works fine if I use WHERE word = 'word'. The WHERE word = "word" is a no-op. From "SQLite Keywords" section of http://www.sqlite.org/lang.html: 'keyword' A keyword in single quotes is interpreted as a literal string if it occurs in a context where a string literal is allowed, otherwise it is understood as an identifier. "keyword" A keyword in double-quotes is interpreted as an identifier if it matches a known identifier. Otherwise it is interpreted as a string literal. -- Tomash Brechko - To unsubscribe, send email to [EMAIL PROTECTED] -
[sqlite] Odd results return by SELECT query WHERE word = "word"
Hi, I am getting weird results when executing a query that has this WHERE clause: WHERE word = "word". The query works fine if I use WHERE word = 'word'. The following illustrates the problem: [EMAIL PROTECTED]:~$ sqlite -version 2.8.17 [EMAIL PROTECTED]:~$ cat populate.sql CREATE TABLE _1_gram (word TEXT, count INTEGER, UNIQUE(word) ); INSERT INTO _1_gram VALUES("foo", 13); INSERT INTO _1_gram VALUES("bar", 16); INSERT INTO _1_gram VALUES("word", 36); INSERT INTO _1_gram VALUES("foobar", 336); [EMAIL PROTECTED]:~$ sqlite test.db < populate.sql [EMAIL PROTECTED]:~$ sqlite test.db SQLite version 2.8.17 Enter ".help" for instructions sqlite> SELECT * FROM _1_gram WHERE word = 'word'; word|36 sqlite> SELECT * FROM _1_gram WHERE word = "word"; foo|13 bar|16 word|36 foobar|336 sqlite> .quit [EMAIL PROTECTED]:~$ Am I missing something here (I haven't used SQL in a while...), or is this a bug? Cheers, - Matteo Vescovi ___ All New Yahoo! Mail Tired of unwanted email come-ons? Let our SpamGuard protect you. http://uk.docs.yahoo.com/nowyoucan.html - To unsubscribe, send email to [EMAIL PROTECTED] -