|
Neohapsis is currently accepting applications for employment. For more information, please visit our website www.neohapsis.com or email hr@neohapsis.com |
From: Elim PDT (elim
pdtnetworks.net)
Date: Tue Jul 21 2009 - 12:43:59 CDT
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Hi Darryle,
Your result was:
+-----------+-------+---------+
| member_id | name | head_id |
+-----------+-------+---------+
| 2 | Ann | 1 |
| 3 | David | NULL |
| 1 | Elim | NULL |
| 5 | Jane | 3 |
| 4 | John | 3 |
+-----------+-------+---------+
which not groups correctly. Seems it's a hard query.
----- Original Message -----
From: "Darryle Steplight" <dsteplight
gmail.com>
To: "Elim PDT" <elim
pdtnetworks.net>
Cc: <mysql
lists.mysql.com>
Sent: Wednesday, July 15, 2009 11:50 PM
Subject: Re: Hard? query to with group order by group head's name
Hi Elim,
I didn't test it out but it sounds like you want to do this "
SELECT * FROM group_members GROUP BY head_id, member_id ORDER BY name
ASC ".
On Thu, Jul 16, 2009 at 1:20 AM, Elim PDT<elim
pdtnetworks.net> wrote:
> My table group_member looks like this:
> +-----------+-------+---------+
> | member_id | name | head_id |
> +-----------+-------+---------+
> | 1 | Elim | NULL |
> | 2 | Ann | 1 |
> | 3 | David | NULL |
> | 4 | John | 3 |
> | 5 | Jane | 3 |
> +-----------+-------+---------+
>
> Record with null head_id means
> the member is a group head.
> Record with head_id k are in the
> group with head whoes id equals k.
>
> I like to fetch the rows in the following ordaer
>
> | 3 | David | NULL |
> | 4 | John | 3 |
> | 5 | Jane | 3 |
> | 1 | Elim | NULL |
> | 2 | Ann | 1 |
>
> That is
> (1) A head-row follewed by the group members with that head
> (2)head rows are ordered alphabetically by name.
>
> What the query looks like?
>
> Thanks
>
>
--
A: It reverses the normal flow of conversation.
Q: What's wrong with top-posting?
A: Top-posting.
Q: What's the biggest scourge on plain text email discussions?
--
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]