SELECT sessions_compare.*
FROM archive_sessions as f_session, sessions_compare
LEFT JOIN archive_sessions as s_session ON (s_session.id = sessions_compare.second_session_id)
LEFT JOIN consols as f_consol ON (f_session.console_id = f_consol.id)
where sessions_compare.first_session_id = f_session.id
after executing a get error like
ERROR: invalid reference to FROM-clause entry for table "f_session" LINE 13:
LEFT JOIN consols as f_consol ON (f_session.console_id =...HINT: There is an entry for table "f_session", but it cannot be referenced from this part of the query.
When i switch places and have from
like sessions_compare, archive_sessions as f_session
i get error like
ERROR: invalid reference to FROM-clause entry for table "sessions_compare" LINE 4: ... archive_sessions as s_session ON (s_session.id = sessions_c...
HINT: There is an entry for table "sessions_compare", but it cannot be referenced from this part of the query.
And only thing that work is
SELECT sessions_compare.*
FROM sessions_compare
LEFT JOIN archive_sessions as s_session ON (s_session.id = sessions_compare.second_session_id)
,archive_sessions as f_session
LEFT JOIN consols as f_consol ON (f_session.console_id = f_consol.id)
where sessions_compare.first_session_id = f_session.id
And my question is it normal ?? Im young in Postgresql in mysql when using multiple join from tables needed to be in ()