mysql query help

Questions about the MySQL, PostgreSQL, and most other databases, as well as using it with PHP can be asked here.

Moderator: General Moderators

Post Reply
adrian29uk
Forum Newbie
Posts: 1
Joined: Thu May 26, 2005 5:58 am

mysql query help

Post by adrian29uk »

I have worked out how to display and group the cars from the database and output this to the page using the following query

$query = "SELECT manufacturer, count(*) AS cnt FROM manufacturers_table WHERE manufacturer= '$manufacturer' GROUP BY manufacturer";

When it outputs it shows me the manufacturer and how many cars the manufacturer has for example

ford (3)

vauxhall (2)


What I would like to able to show is the car models directly underneath the manufacturer and group by models for example

Ford (3)
Fiesta (2), Escort (4), Kar (2)

vauxhall (2)
Vectra (4), Corsa (2)

I have tried and tried with the query but I still cannot get it. If anyone could show me some examples that would be appreciated.

Thank you in advance
User avatar
JayBird
Admin
Posts: 4524
Joined: Wed Aug 13, 2003 7:02 am
Location: York, UK
Contact:

Post by JayBird »

1) How about posting in the correct section
2) Read this - viewtopic.php?t=21171
3) Need to see your DB structure
Post Reply