Re: Sorting results based on 'another table' ..
Hi,
> Using PHP and MySQL, I have a table with top
> categories and another with subcategories. They
> are related by a two-field table where the id's
> from each category bind them together.
If I understand this correctly, you have three tables: Categories, Subcategories and a linking table. This should just be a three table join to output a tree for a single Category (and then sort by Subcategory name). If you want to sort multiple categories and corresponding subcategories, I would use a path delimited string to sort the output. Check this recent post...
http://forums.mysql.com/read.php?10,27713,27713#msg-27713
> Another question: I keep bumping into the question
> of custom sort order. I have a list of members of
> an association, and they want certain members to
> be listed in a certain order (Chairman first
> etc.). So far the only solution I've come up with
> is adding a 'custom sort field' where they can
> enter a custom sort value for each member (005,
> 010, 015 ..) to have the members sorted the way
> they want. Is there another way?
Check this post.
http://forums.mysql.com/read.php?10,27726,27726#msg-27726
You can use conditionals, but I would create a member_rank table instead with a list of members and a rank for sorting. Join your output to this list of rankings and sort the names by the member's rank.
Chris
>
> Thanks in advance,
> Johnny Skaaning