Results 1 to 2 of 2

Thread: Table Joins??

  1. #1
    Join Date
    Sep 2003
    Posts
    1

    Table Joins??

    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

  2. #2
    Join Date
    Mar 2003
    Posts
    468
    don't quite know if this is what you are asking but the columns returned are in the select list. in this case the select list is '*' where '*' will expand to include all the rows from both tables maintable and statetable.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •