|
|
|
|
||||||
![]() |
|
|
LinkBack | Outils de la discussion |
|
|
#1 |
|
Messages: n/a
Hébergeur: |
Hi,
I want to do a join for 4 tables on field "id" and "type" but I only want to have "id" and "type" shown once, then have all the other fields, that are unique in the table, also shown. Something like: select // id and type once, then all fields from table_11 t1, table_12 t2, table_21 t3, table_22 t4 where t1.id=t2.id and t2.id=t3.id and t3.id=t4.id and t1.type=t2.type and t2.type=t3.type and t3.type=t4.type limit 5 Any ideas? Cheers |
|
|
|
#2 |
|
Messages: n/a
Hébergeur: |
On Sat, 19 Apr 2008 12:34:12 +0200, avilella <avilella@gmail.com> wrote:
> Hi, > > I want to do a join for 4 tables on field "id" and "type" but I only > want to have "id" and "type" shown once, then have all the other > fields, that are unique in the table, also shown. Something like: > > select // id and type once, then all fields > from table_11 t1, table_12 t2, table_21 t3, table_22 t4 > where t1.id=t2.id and > t2.id=t3.id and > t3.id=t4.id and > t1.type=t2.type and > t2.type=t3.type and > t3.type=t4.type limit 5 > > Any ideas? Just name them explicitly? -- Rik Wasmus |
|
|
|
#3 |
|
Messages: n/a
Hébergeur: |
Rik Wasmus wrote:
> On Sat, 19 Apr 2008 12:34:12 +0200, avilella <avilella@gmail.com> > wrote: >> Hi, >> >> I want to do a join for 4 tables on field "id" and "type" but I only >> want to have "id" and "type" shown once, then have all the other >> fields, that are unique in the table, also shown. Something like: >> >> select // id and type once, then all fields >> from table_11 t1, table_12 t2, table_21 t3, table_22 t4 >> where t1.id=t2.id and >> t2.id=t3.id and >> t3.id=t4.id and >> t1.type=t2.type and >> t2.type=t3.type and >> t3.type=t4.type limit 5 >> >> Any ideas? > > Just name them explicitly? As Rik said and use explicit JOINs for clarity and reliability |
|
|
|
#4 |
|
Messages: n/a
Hébergeur: |
Rik Wasmus wrote:
> On Sat, 19 Apr 2008 12:34:12 +0200, avilella <avilella@gmail.com> wrote: > >> Hi, >> >> I want to do a join for 4 tables on field "id" and "type" but I only >> want to have "id" and "type" shown once, then have all the other >> fields, that are unique in the table, also shown. Something like: >> >> select // id and type once, then all fields >> from table_11 t1, table_12 t2, table_21 t3, table_22 t4 >> where t1.id=t2.id and >> t2.id=t3.id and >> t3.id=t4.id and >> t1.type=t2.type and >> t2.type=t3.type and >> t3.type=t4.type limit 5 >> >> Any ideas? > > Just name them explicitly? Which is a good practice, anyway. -- ================== Remove the "x" from my email address Jerry Stuckle JDS Computer Training Corp. jstucklex@attglobal.net ================== |
|
![]() |
| Outils de la discussion | |
|
|