开发者

sqlite SELECT returns all records when querying a column for a value with the same name as the column

$ sqlite3 test.db
SQLite version 3.6.21
Enter ".help" for instructions
Enter SQL statements terminated with a ";"
sqlite> CREATE TABLE test(foo text);
sqlite> INSERT INTO test VALUES ("foo");
sqlite> INSERT INTO test VALUES ("bar");
sqlite>开发者_C百科 SELECT * FROM test WHERE foo="foo";
foo
bar
sqlite>

It seems that the query treats "foo" as a reference to the name of the column, rather than as a string constant. How do I get this query to only return foo, not bar? Are there options besides renaming the column?


Sqlite3 Keywords

sqlite> SELECT * FROM test WHERE foo='foo';

use single quotes.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜