[Fixed]-Understanding syntax error at or near "SEPARATOR" after migrating from MySQL to Postgres

1👍

As you’ve already seen you need to replace GROUP_CONCAT() with STRING_AGG(). Include every column that is not used inside an aggregate function in GROUP BY clause.

select 
  p.id, 
  p.title, 
  p.description, 
  p.deadline, 
  pt.name as project_type, 
  s.name as status, 
  sc.name as sport_category, 
  string_agg(au.email, E'\n') as project_managers 
from 
  project p 
  left join project_manager_in_project pmip on p.id = pmip.project_id 
  left join auth_user au on pmip.project_manager_id = au.id 
  inner join project_type pt on p.projectType_id = pt.id 
  inner join status s on p.status_id = s.id 
  inner join sport_category sc on p.sportCategory_id = sc.id
where 
  p.deleted = 0 
group by 1,2,3,4,5,6,7

There is no SEPARATOR keyword in Postgres (at least I’m not aware of its’ existence).

Leave a comment