Often the entire database is too much information. One main job of databases might be to find out specific information, such as "How many customers do we have in California?" or "Which stamps in my collection are worth more than $500?" You could certainly look at all the data and count out these answers by hand, but the computer ought to automate that kind of tedious work, and it can. A query essentially is a question. It returns an answer as a subset of the table. Only the members of the table that answer the question are returned. Queries are comparisons. They always involve field names and sample values. You tell the computer a field and ask it to search for records that relate to a specific value. In our fruit example, if we wanted to find our record for "apple", our query might be something like
NAME = "apple"
What this means to the database is "Show me all the records where the NAME field is equal to the value "apple".
In fact, we might have a number of kinds of apples in our store, like Jonathan apples, Granny Smith apples, and Macintosh apples. (The fruit, not the computer!) We might be able to make a search for fields that contain a value. If we modify the above query to
NAME contains "apple"
we might find all those other apples as well, (although we might also
find pineapple!) The exact syntax of the statements will certainly be
different, but the idea will not change. A query consists of
comparing a certain field with a certain value.
Other kinds of relationships are also possible. If we wanted to search for all the expensive fruit in our store, we might want to have a query something like:
COST_POUND > $1.00 This query should return to us a list of all the records whose COST_POUND field has a value larger than one dollar.
Querying is an example of processing When you do this kind of
work to a database, you are somehow massaging the values in the
database to impart some kind of meaning from them.