Database error: -
select t.id, trim(concat(t.pre, ' ', t.name, ' ', t.extra)) as `theme`, g.name as `group`, g.sort_order from themes t, groups g, themes_groups tg where t.id = tg.theme_id and tg.group_id = g.id order by g.sort_order, t.extra, t.name