|
Posted by laredotornado on 11/28/05 16:16
Hello, I'm using PHP 4 and MySQL 4. Is it possible to write a query
that joins two tables, but if one value cannot be matched, the row
would not be excluded, but a value could be substituted. For example,
if there were two tables
SALES
----------
USER_ID INTEGER UNSIGNED,
TOTAL_SALES FLOAT
and
USERS
-----------
USER_ID INTEGER UNSIGNED,
USERNAME VARCHAR(32) NOT NULL
and they contained the following data
SALES.USER_ID SALES.TOTAL_SALES
-----------------------------------------------------------------
4 55.00
2 125.50
USERS.USER_ID USERS.USERNAME
--------------------------------------------------------------
2 myusername
How could I write a single query tnat would give the following results?
USERNAME TOTAL_SALES
---------------------------------------------------------------
myusername 125.00
(user no longer exists) 55.00
Thanks for your help, - Dave
[Back to original message]
|