I have 5 types of groups in my DB table. i need to group type 1,type 2 and type 3 as a single group, and type 4 as another group and type 5 as another one. How can i do this using cakephp1.3? Please help me anyone
MySQL doesn't support grouping like you are needing to do unless you use CASE within the group by. I wouldn't do it this way because it would require you to re-edit the application code every time you need to change the grouping. You could make and join a second table with a mapping to the types and group by the column in that table. You would map type 1,2,3 to one value, and 4 and 5 to their own, and then group by that column. This way if you add types or need to modify the grouping, you just edit the mapped table. New table: type (corresponding with existing table) group_type You would add the data. type group_type 1 1 2 1 3 1 4 2 5 3 PHP: Then group by the group type after doing an inner join to the new table.