PHWinfo banniere

Titres
PORTAIL ANNUAIRE ARTICLES COMPARATEUR HÉBERGEURS DEVIS FORUMS RÉDUCTEUR D'URL
Précédent   PHWinfo > Autres forums > Forum Programmation & Conception > comp.databases.mysql > select all different fields but only one for the common in join
S'inscrire FAQ Membres Recherche Messages du jour Marquer les forums comme lus
select all different fields but only one for the common in join

Réponse
 
LinkBack Outils de la discussion
Vieux 19/04/2008, 11h34   #1
avilella
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut select all different fields but only one for the common in join

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
  Réponse avec citation
Vieux 19/04/2008, 13h24   #2
Rik Wasmus
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: select all different fields but only one for the common in join

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
  Réponse avec citation
Vieux 19/04/2008, 13h41   #3
Paul Lautman
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: select all different fields but only one for the common in join

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


  Réponse avec citation
Vieux 19/04/2008, 13h44   #4
Jerry Stuckle
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: select all different fields but only one for the common in join

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
==================

  Réponse avec citation
Réponse


Outils de la discussion

Règles de messages
Vous ne pouvez pas créer de nouvelles discussions
Vous ne pouvez pas envoyer des réponses
Vous ne pouvez pas envoyer des pièces jointes
Vous ne pouvez pas modifier vos messages

Les balises BB sont activées : oui
Les smileys sont activés : oui
La balise [IMG] est activée : oui
Le code HTML peut être employé : non
Trackbacks are oui
Pingbacks are oui
Refbacks are oui


Fuseau horaire GMT +1. Il est actuellement 02h41.


Édité par : vBulletin® version 3.7.3
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.2.0 RC5 Tous droits réservés.
Version française #16 par l'association vBulletin francophone
PHWinfo est un site Éducation Sans Frontières ©2000-2008
Ad Management by RedTyger
©Tous droits réservés par les parties respectives
Page generated in 0,10184 seconds with 12 queries