Re: Re: If in a query

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



I think you are not considering all the cases.
Suppose your column is NULL for the first record but it has a non-NULL value
on the second record. So, why do you want your query to return nothing
whereas there are values in it?

                Col1        Col2            Col3
__________________________________
Row1:        18        NULL        abcdf
Row2:        16        28              jdgdkdkf

Do you see what I mean? Column 2 is NULL for the first record but it is 28
for the second record.

A query like:
                    SELECT col1, IFNULL(col2, 0) AS col22, col3 FROM tblName
will return

                Col1        Col2            Col3
__________________________________
Row1:        18        0                abcdf
Row2:        16        28              jdgdkdkf


Thanks
Emery
----- Original Message -----
From: "Shaun" <shaun@mania.plus.com>
To: <php-db@lists.php.net>
Sent: Saturday, September 27, 2003 15:43
Subject:  Re: If in a query


> i'm sorry,
>
> i rushed that previous post!!!
>
> what i meant to ask was, if the value of B.Column1 is null then can the
> query be written such that we dont select A.Column2.
>
> Sorry!
>
> "Shaun" <shaun@mania.plus.com> wrote in message
> 20030927134011.97570.qmail@pb1.pair.com">news:20030927134011.97570.qmail@pb1.pair.com...
> > Hi,
> >
> > is it possible to create a query with parameters such that it selects a
> > field if it isn't null?
> >
> > for example:
> >
> > SELECT
> >   A.Column1,
> >   A.Column2,
> >   (if not null, B.Column1)
> > FROM Table1 A, Table2 B
> >
> > Thanks for your help
>
> --
> PHP Database Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>
>

-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [PHP Users]     [Postgresql Discussion]     [Kernel Newbies]     [Postgresql]     [Yosemite News]

  Powered by Linux