Hi

I have be scratching my head with this for a few days.

I want to select data from 2 tables conditionally. 1 table has users, 
the other times relating to the users. I want to create a query that 
will select the user from the users table and if they have any time 
data against them (for that day) return that also. If there is not data 
for that day only the user data should be returned.

If I do:
SELECT u.id,u.surname,t.* 
FROM users u LEFT OUTER JOIN times t
ON (u.id =t.id) 
WHERE u.id = 22;

I get:
22|Price|NULL|NULL| NULL| NULL| NULL| NULL| NULL| NULL  

Which I could work with but once I add "AND t.date = (current_date) 
I get 0 records returned and I need the users.id an users.surname.

Can anyone think of a way round this?
Thanx.
Dp.
sql,mysql,query.
~~
Dermot Paikkos * [EMAIL PROTECTED]
Network Administrator @ Science Photo Library
Phone: 0207 432 1100 * Fax: 0207 286 8668


---------------------------------------------------------------------
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