View Full Version : select query

07-26-2006, 07:50 PM
below is code which I am using in a query:

SELECT DISTINCT [tblCar].[CarID], [tblCar].[Year] FROM tblCar ORDER BY [Year];

I am trying to have the query so that if two cars are entered into the tblCar and have the same year of manufacture, the year wont be displayed more than once.

Could someone tell me if this is possible and if it, is am I doing it the rite way?? If I am not doing it the rite way then, how?????

07-26-2006, 08:54 PM
You could use:

select group_concat(carid), year
from yourtable
group by year

and it will give you a single row for each year with a comma delimited list of the carids from that year.

alternately, if you are using php to display your information, take a look at the categories/subcategories link in my signature. you should be able to figure out how to use it to show the year once and then a list of the cars below that and then print out the year again when the model year changes.

EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum