Moving mysql union query to postgresql I am trying to move a mysql query to postgresql and I have a problem with the union operation, this is the query:

SELECT        
          "user_firstname"
        , "user_lastname"
        , "course_fullname"
        , "course_completion_completeddate"
        , "course_completion_status"
        , "ESR Employee Number"
        , "DH Job Role"
        , "Department"
        from mdl_course_completions
        union
        SELECT                   
          auser.firstname AS user_firstname,
          auser.lastname AS user_lastname,
          course.fullname AS course_fullname,
          from_unixtime(base.timecompleted) AS course_completion_completeddate,
          CASE WHEN base.status = 50 OR base.status = 75 THEN 'Complete' END AS course_completion_status,
          COALESCE(user_9.data,'') AS user_custom_field_9,
          COALESCE(user_5.data,'') AS user_custom_field_5,
          COALESCE(user_49.data,'') AS user_department           
        FROM mdl_course_completions base
         LEFT JOIN mdl_user auser
             ON auser.id = base.userid
         LEFT JOIN mdl_course course
             ON course.id = base.course 
         LEFT JOIN mdl_user_info_data user_9
            ON user_9.userid = auser.id AND user_9.fieldid = 9
         LEFT JOIN mdl_user_info_data user_5
            ON user_5.userid = auser.id AND user_5.fieldid = 5 
          LEFT JOIN mdl_user_info_data user_49
            ON user_49.userid = auser.id AND user_49.fieldid = 49 
        WHERE
            (base.timecompleted &gt; 1485953790
              and
            base.timecompleted &lt; 1486040190
              and
            base.timecompleted IS NOT NULL)              
              and
            course.id = 1730   
              and
            base.status  IN (50,75)
        ;


The only function doesn't work is from_unixtime, but I changed for to_timestamp and it's ok, the problem is when I execute the query I get this error:

ERROR:  column "user_firstname" does not exist
LINE 2:           "user_firstname"


And I really don't understand why this runs with MySQL but does not with Postgres. Maybe I need to change it to join, so, any ideas?
The issue is relevant to this whole part and not just  "user_firstname".

SELECT        
          "user_firstname"
        , "user_lastname"
        , "course_fullname"
        , "course_completion_completeddate"
        , "course_completion_status"
        , "ESR Employee Number"
        , "DH Job Role"
        , "Department"
        from mdl_course_completions


In MySQL "user_firstname" is interpreted as a string (which probably wasn't you intention)
In PostgreSQL "user_firstname" is interpreted as a column name.



Demo

create table t (x int);
insert into t (x) values (1),(2),(3);

select "x" as col from t;


PostgreSQL

+---+
|col|
+---+
| 1 |
+---+
| 2 |
+---+
| 3 |
+---+


MySQL

+---+
|col|
+---+
| x |
+---+
| x |
+---+
| x |
+---+