Lets say I wanted to select all employees and list their occupations.
I have this query:
SELECT * FROM employees, job WHERE employees.id=job.id
Now some employees might have more than one job. I use PHP to loop through
the results and get this:
Bob
- Driver
Bob
- Cleaner
Dave
- Writer
Mike
- Director
Mike
- Producer
How do I group it to output like this, and can it be done in the query?
Bob
- Driver
- Cleaner
Dave
- Writer
Mike
- Director
- Producer
FYI, My PHP
while($row=mysql_fetch_array($sql)){
echo "$row[name]<br>";
echo " - $row[job]<br>";
}
Appreciate any feedback.
Yobro