PHWinfo banniere

Titres
PORTAIL ANNUAIRE ARTICLES COMPARATEUR HÉBERGEURS DEVIS FORUMS RÉDUCTEUR D'URL
Précédent   PHWinfo > Autres forums > Forum Programmation & Conception > mysql.general > Left join problem
S'inscrire FAQ Membres Recherche Messages du jour Marquer les forums comme lus
Left join problem

Réponse
 
LinkBack Outils de la discussion
Vieux 05/09/2007, 15h38   #1
Kaj Schermer Didriksen
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Left join problem

Hi
two tables gi_t and gi

gi_t holds 5 records. gi holds ca. 1500.

I need all from gi for each in gi_t ie LEFT JOIN!!!
but this:
SELECT gi.id AS id, overskrift,gidata FROM gi_t LEFT JOIN gi ON
gi_t.id=gi.gitref WHERE bladref=137
gives the same as
SELECT gi.id AS id, overskrift,gidata FROM gi_t ,gi WHERE
gi_t.id=gi.gitref AND bladref=137

I want 5 records (3 ok, and 2 NULL) and I get 3. the 3 that has a
relation in gi

why?
Regards
Kaj Schermer Didriksen
  Réponse avec citation
Vieux 05/09/2007, 16h37   #2
Jerry Schwartz
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut RE: Left join problem

Which table is bladref in?

Regards,

Jerry Schwartz
The Infoshop by Global Information Incorporated
195 Farmington Ave.
Farmington, CT 06032

860.674.8796 / FAX: 860.674.8341

www.the-infoshop.com
www.giiexpress.com
www.etudes-marche.com


> -----Original Message-----
> From: Kaj Schermer Didriksen [mailto:kaj@macron.dk]
> Sent: Wednesday, September 05, 2007 10:39 AM
> To: mysql@lists.mysql.com
> Subject: Left join problem
>
> Hi
> two tables gi_t and gi
>
> gi_t holds 5 records. gi holds ca. 1500.
>
> I need all from gi for each in gi_t ie LEFT JOIN!!!
> but this:
> SELECT gi.id AS id, overskrift,gidata FROM gi_t LEFT JOIN gi ON
> gi_t.id=gi.gitref WHERE bladref=137
> gives the same as
> SELECT gi.id AS id, overskrift,gidata FROM gi_t ,gi WHERE
> gi_t.id=gi.gitref AND bladref=137
>
> I want 5 records (3 ok, and 2 NULL) and I get 3. the 3 that has a
> relation in gi
>
> why?
> Regards
> Kaj Schermer Didriksen
>




  Réponse avec citation
Vieux 05/09/2007, 17h00   #3
Martijn Tonies
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: Left join problem

Hi,

> two tables gi_t and gi
>
> gi_t holds 5 records. gi holds ca. 1500.
>
> I need all from gi for each in gi_t ie LEFT JOIN!!!
> but this:
> SELECT gi.id AS id, overskrift,gidata FROM gi_t LEFT JOIN gi ON
> gi_t.id=gi.gitref WHERE bladref=137
> gives the same as
> SELECT gi.id AS id, overskrift,gidata FROM gi_t ,gi WHERE
> gi_t.id=gi.gitref AND bladref=137
>
> I want 5 records (3 ok, and 2 NULL) and I get 3. the 3 that has a
> relation in gi


Where does "bladref" come from? As soon as you use
multiple tables in your query, it's good practice to prefix
each column with the table (or alias) it comes from.

Can you give the table metadata and sample data for
your rows?

Martijn Tonies
Database Workbench - development tool for MySQL, and more!
Upscene Productions
http://www.upscene.com
My thoughts:
http://blog.upscene.com/martijn/
Database development questions? Check the forum!
http://www.databasedevelopmentforum.com
  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 16h22.


É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,12863 seconds with 11 queries