"Maxim Maletsky" <[EMAIL PROTECTED]> wrote:
> As you can see, the main data is in 'accounts', the 'addresses.ID' is
UNIQUE
> and corresponds to 'accounts.ID'. The fact is that not every account has
an
> address registered with it.
<snip>
> FROM
> accounts,
> addresses
You're doing a straight join. You need to use a LEFT JOIN to return all the
records from one table and those from a second table that match based on a
common field. Read about joins in the manual and find a resource on SQL
statements - it'll pay off.
SELECT *
FROM accounts
LEFT JOIN addresses
ON addresses.ID = accounts.ID
> Can anyone suggest me how do I SELECT ALL of the accounts having simply
NULL
> on 'addresses.*' when there's no such row, instead of 'loosing' the whole
> 'account' row?
Use the query above and add:
WHERE addresses.ID IS NULL
--
Steve Werby
President, Befriend Internet Services LLC
http://www.befriend.com/
---------------------------------------------------------------------
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