General SQL syntax
A simple SQL query:
select <ValueField>, <DisplayField>
from <Table>
where <Some Condition>
The first column must be the value for the list item and the second column the display for the list item.
A select statement can also return a single column:
select <ValueField>
from <Table>
where <Some Condition>
In this example, the column will be used for both the value and display for the list item.
A conditional select statement:
select “Customer Id”, “Customer Name”
from “Customers”
where “Customer Name” = ‘Fred’
In this example, all customers where Customer Name is “Fred” will be returned.
A conditional select statement using wildcard symbols:
select “Customer Id”, “Customer Name”
from “Customers”
where “Customer Name” like ‘%Johnson’
In this example, all customers where Customer Name ends with the text “Johnson” will be returned. For example, customers where Customer Name is “FJohnson”, “FredJohnson”, “Johnson” or “3Johnson” will be returned.
SQL wildcard syntax is used with the like operator. The wildcard % is used to specify a wildcard for one or more character.