Query Statements

Once data has been loaded into a table, you run queries against the table using a SELECT statement. For example, if you wanted to get the third entry, you could do this:

Download SQLite/selectid.sql

select * from mytable where(_id=3);

It's more likely you'd want to look up a person's phone number by name. Here's how you'd find all the records containing "Smith" in the name:

Download SQLite/selectwhere.sql

select name, phone from mytable where(name like "%smith%");

Keep in mind that SQL is case insensitive. Keywords, column names, and even search strings can be specified in either uppercase or lowercase.

Now you know just enough about SQL to be dangerous. Let's see how to put that knowledge to work in a simple program.

0 0

Post a comment