|
|
|
#1 |
|
Messages: n/a
Hébergeur: |
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 |
|
|
|
#2 |
|
Messages: n/a
Hébergeur: |
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 > |
|
|
|
#3 |
|
Messages: n/a
Hébergeur: |
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 |
|
![]() |
| Outils de la discussion | |
|
|