Sorting Results in MySQL

Discussion in 'Programming/Scripts' started by badben, Jul 5, 2006.

  1. badben

    badben New Member

    I have a problem trying to sort results in mysql with tables as follows:

    Table: Jobs

    job_id category_id employer ......
    1 1 fred
    2 1 joe
    3 2 ken
    . . .
    . . .
    . . .

    Table: Categories

    cat_id cat_description
    1 engineering
    2 accountancy
    . .
    . .

    How do I sort through the results of a query on the job table by cat_description alphabetically (which is in another table linked by cat_id)
     
  2. sjau

    sjau Local Meanie Moderator

    Query is something like this:

    PHP:
    $sql "SELECT * FROM Jobs, Categories WHERE Jobs.category_id=Categories.cat_id ORDER BY cat_description ASC";
    $result mysql_query($sql);
     

Share This Page