NULL values

------=_NextPart_000_0025_01CB9330.A255DB00
Content-Type: text/plain;
charset="UTF-8"
Content-Transfer-Encoding: quoted-printable


When I do the following query in mySQL only 1 record is retrieved.

SELECT * FROM `paypal_payment_info` WHERE `os1` NOT LIKE =
'commission_paid'

I am surprised by this. This one record has no characters in it, but =
the =E2=80=9CINSERT INTO=E2=80=9D that created it used: ( `os1` ) VALUES =
( =E2=80=98=E2=80=99 ) instead of: ( `os1` ) VALUES ( NULL ) . There =
are a number of records where `os1` is NULL. I would like these rows to =
retrieve as well. How do I make a WHERE clause for a cell that is NULL =
?

Ron

The Verse of the Day
=E2=80=9CEncouragement from God=E2=80=99s Word=E2=80=9D
http://www.TheVerseOfTheDay.info

------=_NextPart_000_0025_01CB9330.A255DB00--
ron.piggott [ Sa, 04 Dezember 2010 03:25 ] [ ID #2051283 ]

Re: NULL values

On Fri, Dec 3, 2010 at 6:25 PM, Ron Piggott
<ron.piggott [at] actsministries.org> wrote:
>
> When I do the following query in mySQL only 1 record is retrieved.
>
> SELECT * FROM `paypal_payment_info` WHERE `os1` NOT LIKE 'commission_paid=
'
>
> I am surprised by this. =A0This one record has no characters in it, but t=
he =93INSERT INTO=94 that created it used: ( `os1` ) VALUES ( =91=92 ) inst=
ead of: ( `os1` ) VALUES ( NULL ) . =A0There are a number of records where =
`os1` is NULL. =A0I would like these rows to retrieve as well. =A0How do I =
make a WHERE clause for a cell that is NULL ?
>

You need to explicitly check for NULLs. The regular operators (<, >,
=3D, LIKE) work on values. NULL columns have no value, so you need to
use IS NULL or IS NOT NULL. Also, if you're not doing wildcard
matches, you should probably just use <> or =3D:

SELECT * FROM `paypal_payment_info` WHERE (`os1` <> 'commission_paid'
OR `os` IS NULL)

Scotty

--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
Scotty Logan [ Sa, 04 Dezember 2010 03:56 ] [ ID #2051284 ]

Re: NULL values

--20cf3054a703bfbbf10496941e68
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: quoted-printable

Dear Ron

Or try this

SELECT * FROM `paypal_payment_info` WHERE ifnull(os1, '') <>
'commission_paid'
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
regds
amit

"The difference between fiction and reality? Fiction has to make sense."


On Sat, Dec 4, 2010 at 7:55 AM, Ron Piggott
<ron.piggott [at] actsministries.org>wrote:

>
> When I do the following query in mySQL only 1 record is retrieved.
>
> SELECT * FROM `paypal_payment_info` WHERE `os1` NOT LIKE 'commission_paid=
'
>
> I am surprised by this. This one record has no characters in it, but the
> =E2=80=9CINSERT INTO=E2=80=9D that created it used: ( `os1` ) VALUES ( =
=E2=80=98=E2=80=99 ) instead of: (
> `os1` ) VALUES ( NULL ) . There are a number of records where `os1` is
> NULL. I would like these rows to retrieve as well. How do I make a WHER=
E
> clause for a cell that is NULL ?
>
> Ron
>
> The Verse of the Day
> =E2=80=9CEncouragement from God=E2=80=99s Word=E2=80=9D
> http://www.TheVerseOfTheDay.info
>

--20cf3054a703bfbbf10496941e68--
Amit Tandon [ Sa, 04 Dezember 2010 12:40 ] [ ID #2051285 ]

Re: NULL values

On 4 December 2010 11:40, Amit Tandon <attand [at] gmail.com> wrote:
> Dear Ron
>
> Or try this
>
> SELECT * FROM `paypal_payment_info` WHERE ifnull(os1, '') <>
> 'commission_paid'
> =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
> regds
> amit
>
> "The difference between fiction and reality? Fiction has to make sense."
>
>
> On Sat, Dec 4, 2010 at 7:55 AM, Ron Piggott
> <ron.piggott [at] actsministries.org>wrote:
>
>>
>> When I do the following query in mySQL only 1 record is retrieved.
>>
>> SELECT * FROM `paypal_payment_info` WHERE `os1` NOT LIKE 'commission_pai=
d'
>>
>> I am surprised by this. =C2=A0This one record has no characters in it, b=
ut the
>> =E2=80=9CINSERT INTO=E2=80=9D that created it used: ( `os1` ) VALUES ( =
=E2=80=98=E2=80=99 ) instead of: (
>> `os1` ) VALUES ( NULL ) . =C2=A0There are a number of records where `os1=
` is
>> NULL. =C2=A0I would like these rows to retrieve as well. =C2=A0How do I =
make a WHERE
>> clause for a cell that is NULL ?
>>
>> Ron
>>
>> The Verse of the Day
>> =E2=80=9CEncouragement from God=E2=80=99s Word=E2=80=9D
>> http://www.TheVerseOfTheDay.info
>>
>

http://dev.mysql.com/doc/refman/5.0/en/comparison-operators. html#function_i=
snull

where isnull(column, '') <> 'value'



--
Richard Quadling
Twitter : EE : Zend
[at] RQuadling : e-e.com/M_248814.html : bit.ly/9O8vFY

--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
Richard Quadling [ Sa, 04 Dezember 2010 19:30 ] [ ID #2051286 ]
PHP » gmane.comp.php.database » NULL values

Vorheriges Thema: Off Topic: Need help with LAN card Issue
Nächstes Thema: Re: [PHP] Closing Browser