guitarist809 Posted March 15, 2007 Share Posted March 15, 2007 Hello. I've got a little problem that I think is easy to resolve. I'm grabbing a bunch of entries from a table with a date field (YYYY-MM-DD), but I only want one field per day for example, I might have a few entries for 2005-03-25, but I only want the first of that. I was looking at those JOIN things, but I couldn't figure them out. Can anybody help me? Thanks, -Matt Link to comment https://forums.phpfreaks.com/topic/42843-mysql-sort-question/ Share on other sites More sharing options...
fenway Posted March 15, 2007 Share Posted March 15, 2007 Depends what you actually mean by "first". Link to comment https://forums.phpfreaks.com/topic/42843-mysql-sort-question/#findComment-208027 Share on other sites More sharing options...
guitarist809 Posted March 15, 2007 Author Share Posted March 15, 2007 It really doesnt matter. I'm just trying to increment a variable by one if there is an event in one day. It's now incrementing by 3 in one day if theres three activities in one day, which makes everything wrong =\. Link to comment https://forums.phpfreaks.com/topic/42843-mysql-sort-question/#findComment-208030 Share on other sites More sharing options...
fenway Posted March 15, 2007 Share Posted March 15, 2007 GROUP BY date? Link to comment https://forums.phpfreaks.com/topic/42843-mysql-sort-question/#findComment-208126 Share on other sites More sharing options...
guitarist809 Posted March 15, 2007 Author Share Posted March 15, 2007 Not Necessairly. Take this example of a table [date] [value] [2007-1-1] [valueasdf] [2007-1-1] [valuasdfe] [2007-1-2] [valuade] [2007-1-3] [vafalue] [2007-1-3] [vadfalue] [2007-1-3] [valdfue] [2007-1-4] [valsdfaue] [2007-1-4] [valdsue] [2007-1-5] [valfdue] [2007-1-8] [valsfue] I just want MySQL to return this [2007-1-1] [valueasdf] [2007-1-2] [valuade] [2007-1-3] [vafalue] [2007-1-4] [valsdfaue] [2007-1-5] [valfdue] [2007-1-8] [valsfue] Notice how none of the dates are the same. I dont care what it returns, just as long as there are no equal dates. The reason I dont care is because i'm not taking the value, its just counting each day. Link to comment https://forums.phpfreaks.com/topic/42843-mysql-sort-question/#findComment-208142 Share on other sites More sharing options...
artacus Posted March 15, 2007 Share Posted March 15, 2007 Yeah, like fenway said, group by date. SELECT `date`, val FROM myTable GROUP BY `date` Link to comment https://forums.phpfreaks.com/topic/42843-mysql-sort-question/#findComment-208172 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.