PDA

View Full Version : Sorting Results in MySQL


badben
5th July 2006, 15:10
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)

sjau
5th July 2006, 15:28
Query is something like this:

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