Thanks to you all for your replies. I was able to solve my problem after
some more reading in the manual:
select c.id, c.name, pc.person_id
from person as p
cross join course as c
left outer join person_course as pc
on (p.id = pc.person_id and c.id = pc.course_id)
where p.id = 2;
A
Tim Tassonis <[EMAIL PROTECTED]> schrieb:
> This is absolutely not what I want. I want a row for every person and every
> course, regardless whether the person has taken the course or not. If the
> person has not taken the course, I want a null value in the person id
> column:
test=# select c
Tim Tassonis <[EMAIL PROTECTED]> writes:
> 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;
> wil
Tim Tassonis wrote:
Hi Andreas
First, you should use referential integrity:
I do, that is not the point. It was a simplified data model. Of course I
have primary keys and stuff, but they don't affect join behaviour at all.
test=# create table person(id int primary key, name text);
NOTIC
Hi,
Without restriction you're getting:
On Fri, Dec 22, 2006 at 02:55:56PM +0100, Tim Tassonis wrote:
> +---+-++
> | id| name| person_id |
> +---+-++
> | 1
Hi Andreas
First, you should use referential integrity:
I do, that is not the point. It was a simplified data model. Of course I
have primary keys and stuff, but they don't affect join behaviour at all.
test=# create table person(id int primary key, name text);
NOTICE: CREATE TABLE / PRIMA
am Fri, dem 22.12.2006, um 12:12:06 +0100 mailte Tim Tassonis folgendes:
> Hi all
>
> I have a join problem that seems to be too difficult for me to solve:
>
> I have:
>
> table person
> id integer,
> namevarchar(32)
>
> data:
>
> 1,"Jack"
> 2,"Jill"
> 3,"Bob"
>
Hi all
I have a join problem that seems to be too difficult for me to solve:
I have:
table person
id integer,
namevarchar(32)
data:
1,"Jack"
2,"Jill"
3,"Bob"
table course
id integer,
name varchar(32)
data:
1,"SQL Beginner"
2,"