Re: while loop

From: Date: Wed, 23 Feb 2005 19:59:10 +0000
Subject: Re: while loop
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-209284@lists.php.net to get a copy of this message
Reinhart Viane wrote:
Well I'm able to do that, there are only 4 different types, but the 4 queries have exactly the same syntax so I think it's better to combine them. Not?
Since mysql 4.1 you can use GROUP_CONCAT() function: SELECT Act_date, Act_type_id, LEFT( GROUP_CONCAT(Act_name
                   ORDER BY Act_date
                   SEPARATOR '|'),
      129 ) as Act_names
FROM activities GROUP BY Act_date, Act_type_id; Act_names will be string containing the names separated by | 129 is the maximum size of Act_name * 2 + 1 for the separator.
-----Oorspronkelijk bericht----- Van: Justin Lilly [mailto:justinlilly@gmail.com] Verzonden: woensdag 23 februari 2005 18:57 Aan: php-general@lists.php.net Onderwerp: Re: [PHP] while loop Perhaps it is just me, but wouldn't it be easier to make individual mysql queries for each different act type? That would make the sorting -much- easier. I'm not sure if that's an option, but if it is, I'd consider exploring it. select * from activities where act_date >= NOW() && act_type_id = 1 or something of that nature. -justin


« previous php.general (#209284) next »