Thanks for your answer. It's quite logical indeed...

I'm new to SQL !

Does it mean that I can't query on several tables at once if some keys have
a NULL value or is there another way ?

What I want is one line for my peopleId 2, built with informations from
several tables... Or in other words I want to get this "virtual table" and
then I want to be able to scroll through every people to display each
people information (sorry if my english is not clear) :

+----------+------+------+
| PeopleID | zip  | city |
+----------+------+------+
| 1        | 1    | aaa  |
+----------+------+------+
| 2        | Null | Null |
+----------+------+------+
| 3        | Null | Null |
+----------+------+------+
| 4        | 3    | ccc  |
+----------+------+------+



Thanks anyway
Michael


A 11:05 07/12/2001 -0800, vous avez écrit :
>Michael
>
>do the first join
>people.zip = city.zip
>
>yo get 2 rows from people 1 and 3
>
>notice there is no peopleid 2 from first join so correct answer is to retun
>null
>
>Rick
>
>-----Original Message-----
>From: Michaël Delorme [mailto:[EMAIL PROTECTED]]
>Sent: Friday, December 07, 2001 11:00 AM
>To: [EMAIL PROTECTED]
>Subject: Query and join problem with null values
>
>
>Hi guys
>
>I have a problem on a SQL query : I got no records selected. Below
>is a sample of my 2 tables :
>
>****
>A table identifying people, containing their adress therefore a ZIP
>code. However for some people I don't have their adress, so no ZIP code :
>
>Table People
>+----------+------+
>| PeopleID | zip  | ...
>+----------+------+
>| 1        | 1    |
>| 2        | Null |
>| 3        | Null |
>| 4        | 3    |
>|         ...     |
>+----------+------+
>
>****
> Another table describe ZIP codes and cities :
>
>Table City
>+-----+------+
>| zip | city | ...
>+-----+------+
>| 1   | aaa  |
>| 2   | bbb  |
>| 3   | ccc  |
>| 4   | ddd  |
>| 5   | eee  |
>|    ...     |
>+-----+------+
>
>Here is my query :
>
>SELECT
>  people.peopleId,
>  people.zip,
>  city.city
>
>FROM
>  people,
>  city
>
>WHERE
>  people.zip = city.zip
>  and people.peopleId = "2";
>
>I don't get any selection... wheras I expect :
>+----------+------+------+
>| PeopleID | zip  | city |
>+----------+------+------+
>| 2        | Null | Null |
>+----------+------+------+
>
>
>Where am I wrong ?
>Thanks in advance
>Michael
>
>
>Here are the table definitions :
>
>CREATE TABLE `people` (
>  `peopleId` tinyint(1) unsigned NOT NULL auto_increment,
>  `zip` varchar(255) default NULL,
>  PRIMARY KEY  (`peopleId`)
>)
>
>CREATE TABLE `city` (
>  `zip` tinyint(1) unsigned NOT NULL auto_increment,
>  `city` varchar(255) default NULL,
>  PRIMARY KEY  (`zip`)
>)
>
>
>__________________________________________
>Michael Delorme
>GIS Manager
>French Mediterranean Botanical Conservancy
>mailto:[EMAIL PROTECTED]
>
>---------------------------------------------------------------------
>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