Hi all
I have a join problem that seems to be too difficult for me to solve:
I have:
table person
id integer,
name varchar(32)
data:
1,"Jack"
2,"Jill"
3,"Bob"
table course
id integer,
name varchar(32)
data:
1,"SQL Beginner"
2,"SQL Advanced"
table person_course
person_id number,
course_id number
data:
(currently empty)
Now, I would like to know for every person the courses they have taken.
In mysql, the following statement:
SELECT c.id, c.name, pc.person_id
FROM person as p
left outer join person_course as pc on p.id = pc.person_id
right outer join course as c on pc.course_id = c.id
where p.id = 2 order by 1;
will get me the following result:
+---+-----------------------------------------+----------+
| id| name | person_id|
+---+-----------------------------------------+----------+
| 1 | SQL Beginner | |
| 2 | SQL Advanced | |
+---+-----------------------------------------+----------+
Can I get Postgres to give me the same result somehow? The above
statement will return nothing at all under postgres.
Bye
Tim