$ 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> 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?
SQLite SELECT statement is used to fetch the data from a SQLite database table which returns data in the form of a result table. These result tables are also called result sets.
With SQL, how do you select all the records from a table named "Persons" where the value of the column "FirstName" starts with an "a"? SELECT * FROM Persons WHERE FirstName LIKE 'a%';
SELECT statements An SQL SELECT statement retrieves records from a database table according to clauses (for example, FROM and WHERE ) that specify criteria. The syntax is: SELECT column1, column2 FROM table1, table2 WHERE column2='value';
Sqlite3 Keywords
sqlite> SELECT * FROM test WHERE foo='foo';
use single quotes.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With