Select And Compare
These tips are mostly applicable to all forms of SQL, some are specific to SQLite and versions of SQLite like RealSQL Databases and RealSQL Server databases.
Finding your data - Logical Operators
In the last lesson we looked at the Select command. You will use this a lot.
Now we are going to look at some of the operators and functions used to build queries. The first one and the most obvious is:
select * from QiSQL_Parents where last_name = 'Brown'
No explanation needed there. Select all the records with a last name of 'Brown'
<> Not Equal
select * from QiSQL_Parents where last_name <> 'Brown'
You can also use != if you want.Now we're Selecting any records where the last name does not equal brown
> Greater Than
select * from QiSQL_Parents where last_name > 'Brown'
Yes, why not? SQL will not only check numeric values are bigger but will alphabetically test as well
>= Greater than OR Equal To
select * from QiSQL_Parents where id >= 1
This should return every row. IDs are automatically generated and start at 1, so the query asking for any row greater than or equal to 1 should return them all
< Smaller Than
select * from QiSQL_Parents where id < 2
<= Smaller than OR Equal To
select * from QiSQL_Parents where id <= 1