Hello All,
I am having trouble re-ordering a table. I believe I know where the problem is (the way the two tables are joined), but am at a loss to work out how to fix it. What I want to do is have the Order By CategoryName, order by when it was entered into the database (PKID I believe) instead of alphabetically.
Below is the code and examples
[php] if(!isset($query)){
$query ="SELECT c.PkID, c.CategoryName, c.ParentID, c.CategoryName as sort, NULL as Selected
FROM " . HC_TblPrefix . "categories c
LEFT JOIN " . HC_TblPrefix . "eventcategories ec ON (c.PkID = ec.CategoryID)
WHERE c.ParentID = 0 AND c.IsActive = 1
GROUP BY c.PkID
UNION SELECT c.PkID, c.CategoryName, c.ParentID, c2.CategoryName as Sort, NULL as Selected
FROM " . HC_TblPrefix . "categories c
LEFT JOIN " . HC_TblPrefix . "categories c2 ON (c.ParentID = c2.PkID)
LEFT JOIN " . HC_TblPrefix . “eventcategories ec ON (c.PkID = ec.CategoryID)
WHERE c.ParentID > 0 AND c.IsActive = 1
GROUP BY c.PkID
ORDER BY sort, ParentID, CategoryName”;
}//end if[/php]
current example looks like…
Age Group
Adults
Babies
Family Events
Pre-School
Primary School
Seniors
Teens
They were imported as
Baby
Pre-School
Primary School
Teens
etc
Any help with this would be greatly appreciated.