Query question

Hello.

I have a daybook/diary style page at the moment that I want to update.

basically this calender logs car regs and their jobs into alotted dates.

If the same reg comes on more than once within one date I would like to only display 1 and show the number of them - with a button which allows them to see all those vehicles job if they want

example…

monday

SBS 911
SBS 911
SBS 911

I would prefer…

SBS 911 - 3

SELECT veh_reg, veh_date, eas_no, COUNT('veh_reg') FROM daybook_db NATURAL JOIN job_db WHERE veh_date>=('$datesrc') AND veh_date<=('$datesrc2') GROUP BY veh_reg

you can see what I am trying to do but not sure If i should just have a normal query and then try and adjust the results with php statement…???

any ideas?

I think you just need to order it by count(veh_reg)…
And, you would have to use UNIQUE(veh_reg) or something like that so you get just one entry for veh_reg…

There are lots of samples online for this…
Here’s one…
http://stackoverflow.com/questions/1002349/using-distinct-and-count-together-in-a-mysql-query

Good luck…

Yeah I understand what you mean with it but as the search will bring up multiple vehicles through a date search…it is slightly different.

search brings up all vehicles with jobs within certain dates.

getting a bit complex for my skilllllz or lack of now.

Sorted!

Nice, perhaps you should post the solution query so others will understand how you solved it…

Glad to hear you solved it, always nice to get thru a programming puzzle…

Sponsor our Newsletter | Privacy Policy | Terms of Service