List:General Discussion« Previous MessageNext Message »
From:Gerald Clark Date:July 25 2002 7:44pm
Subject:Re: how to retrieve data from two table?
View as plain text  

Dermot Paikkos wrote:

>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)
>
AND  ( t.date = (current_date) or t.date IS NULL )

> 
>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 * dermot@stripped
>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 <mysql-thread115548@stripped>
>To unsubscribe, e-mail
> <mysql-unsubscribe-gerald_clark=suppliersystems.com@stripped>
>Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php
>
>


Thread
how to retrieve data from two table?Dermot Paikkos25 Jul
  • Re: how to retrieve data from two table?Benjamin Pflugmann25 Jul
  • Re: how to retrieve data from two table?Gerald Clark25 Jul
  • Re: how to retrieve data from two table?Dicky Wahyu Purnomo26 Jul