I have this member table where memberships are either single or family, and if family they can be family head or dependent. When outputting a view of the membership, it currently sorts alpha ascending, but I'd like to find a way to put all of the dependents of a family head below the head.
The relevant columns are:
isFam ( tinyint(1) )
isFamHead ( tinyint(1) )
memKey ( int(11) )
Is there some way, in a mysql query, to sort the table alphabetically for single members and family heads, but put the dependents of the family head directly beneath the family head?
(This sort of works right now if all family members have the same last name, but in many cases I find they don't. And different families can have the same last name as well, so ...)
From the comments:
memKey
identifies a membership. For a single membership, there will be only one row with thatmemKey
; for a family membership, all members of a given family will have the samememKey
.- For a single membership,
isFam
is 0; for all members of family memberships,isFam
= 1. - The "family head" of each family membership has
isFamHead
= 1; there should only be one row whereisFamHead
= 1 permemKey
. (Ignore value ofisFamHead
for single members)