Postgresql - Can I do a join in a function?
Yes, except the Postgres syntax through CREATE FUNCTION is  more natural:

CREATE FUNCTION my_proc(myOpt bool, myParam varchar)
RETURNS SETOF (types)
AS $$
  SELECT types
  FROM my_table1 t1
  INNER JOIN table2 AS t2 USING (id)
  WHERE myOpt AND t2.param = myParam
$$ LANGUAGE sql;


If you need a more complex procedural language check out PL/pgSQL