Peter,

If you would like to get such resultset

> name    field1     field2   field3    field4   field5   field6
> -----------------------------------------------------------------
> test         1            2          5          6          9         10
> test         1            2          5          6         11        12
> test2       3            4       NULL    NULL      15        16

then you need to use left join for t2, but based only on these information
I couldn't help you to implement this query (I don't know how to group by
rows).
Please, give more information about why do you need exactly this resultset.

Best regards,
Mikhail.

----- Original Message -----
From: "Peter Stöcker" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Thursday, September 19, 2002 11:03 AM
Subject: JOIN-Question


> Hi there!
>
> I have a question on JOINs.
>
> First the system:
>
> table1: name: t1
>             entries:     name  field1  field2
>                              ------------------------
>                              test       1         2
>                              test2     3         4
>
> table2: name t2
>             entries:     name  field3  field4
>                              ------------------------
>                              test       5         6
>                              test       7         8
>
> table3: name t3
>             entries:     name  field5  field6
>                              ------------------------
>                              test       9         10
>                              test       11       12
>                              test2     13       14
>                              test2     15       16
>
> And here the problem:
>
> with the query
>
> SELECT a.*, b.*, c.* FROM t1 a INNER JOIN t2 b USING(name) INNER JOIN t3 c
USING(name) WHERE b.field3=7 OR c.field6=16;
>
> I only get 1 entry with name="test".
>
> By using LEFT JOIN I only get name="test" either. For sure, because in
table2 there is no test2 entry.
>
> The only 2 ways I know to get also test2:
> 1. "INSERT INTO t2 VALUES("test2",NULL,NULL)"
> 2. temporary table
>
> But I don't want to have such dummy entries or a temporary table. Does
anybody know what I have to do to with:
>
> SELECT a.*,b.*,c.* FROM ?????? WHERE b.field3=5 OR c.field6=16
>
>
> the result:
>
>
> name    field1     field2   field3    field4   field5   field6
> -----------------------------------------------------------------
> test         1            2          5          6          9         10
> test         1            2          5          6         11        12
> test2       3            4       NULL    NULL      15        16
>
>
> I hope that someone can help me!
>
> Thank a lot,
> Peter
>
____________________________________________________________________________
__
> WEB.DE MyPage - Ultimatives Kommunikationstool! Ihre Message sofort
> online! Domain aenderbar! http://www.das.ist.aber.ne.lustige.sache.ms/
>
>
> ---------------------------------------------------------------------
> Before posting, please check:
>    http://www.mysql.com/manual.php   (the manual)
>    http://lists.mysql.com/           (the list archive)
>
> To request this thread, e-mail <[EMAIL PROTECTED]>
> To unsubscribe, e-mail
<[EMAIL PROTECTED]>
> Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php
>


---------------------------------------------------------------------
Before posting, please check:
   http://www.mysql.com/manual.php   (the manual)
   http://lists.mysql.com/           (the list archive)

To request this thread, e-mail <[EMAIL PROTECTED]>
To unsubscribe, e-mail <[EMAIL PROTECTED]>
Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php

Reply via email to