List:General Discussion« Previous MessageNext Message »
From:Daniel Smith Date:January 17 2007 7:02pm
Subject:Re: Having problems with what appears to be a simple query.
View as plain text  
On Wed, 2007-01-17 at 11:47 -0600, Peter Brawley wrote:
> Daniel,
> 
> CREATE TABLE tbl (
>   lab_number int(11) default NULL,
>   result int(11) default NULL,
>   release_time datetime default NULL
> );
> select * from tbl;
> +------------+--------+---------------------+
> | lab_number | result | release_time        |
> +------------+--------+---------------------+
> |          1 |     10 | 2007-01-17 00:00:00 |
> |          1 |     20 | 2007-01-17 00:00:00 |
> |          2 |      5 | 2007-01-17 00:00:00 |
> |          2 |   NULL | 0000-00-00 00:00:00 |
> |          3 |   NULL | 0000-00-00 00:00:00 |
> |          4 |     25 | 0000-00-00 00:00:00 |
> |          4 |     35 | 0000-00-00 00:00:00 |
> +------------+--------+---------------------+
> 
> SELECT t1.lab_number,t1.result,t1.release_time
> FROM tbl t1
> LEFT JOIN tbl t2 ON t1.lab_number=t2.lab_number AND t2.result IS NULL
> WHERE t1.release_time=0 AND t2.lab_number IS NULL
> 
> +------------+--------+---------------------+
> | lab_number | result | release_time        |
> +------------+--------+---------------------+
> |          4 |     25 | 0000-00-00 00:00:00 |
> |          4 |     35 | 0000-00-00 00:00:00 |
> +------------+--------+---------------------+
> 
> PB
This works!!  It seems it was my defaults for my original table that was
causing me my problems.  Sorry for troubling you, thanks once again for
the prompt solution.

Danny
Thread
Having problems with what appears to be a simple query.Daniel Smith17 Jan
  • Re: Having problems with what appears to be a simple query.Peter Brawley17 Jan
    • Re: Having problems with what appears to be a simple query.Daniel Smith17 Jan
      • Re: Having problems with what appears to be a simple query.Peter Brawley17 Jan
        • Re: Having problems with what appears to be a simple query.Daniel Smith17 Jan