I have created a search page that returns values of the main table in my database. However the main table has some columns/fields that are only populated by foreign keys of other tables in my DB. An example is I have a table for states, and each state is given a number. This number is the primary key, and appears as the foreign key in my main table, and then also the search results.

For example, if someone searches for california, in states (in main table) it will say '1' instead of california. How can I make it so that if someone searches my main table for california, it will return the value 'california' from the states table instead?

I have had a response from this question before that appears below, ans this was fine. However, I would like to know how this works where stateTable uses a variable such as $HTTP_GET_VARS['stateID'']
Where would the varstateID fit into the statement below??

SELECT *
FROM maintable, stateTable
WHERE maintable.stateID = stateTable.stateID


Thanks in advance for any help!!

Cheers
Gear