Re: php explained in sql

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

 



John Taylor-Johnston wrote:
In php, if I wanted to know if $mydata->email contained something, I would do this, right?
if ($mydata->email)
{}

How would I express this in SQL (MySQL)?

That doesn't tell you if $mydata->email contains something. It tells you whether the value of $mydata->email, when cast to boolean, equals TRUE. If $mydata->email equaled zero or the string "0", it would still contain something, but that if statement would not get executed.

In MySQL, it would depend on the datatype. You could do any of the following, depending on what you actually want to do:

	colname<>''
	colname<>0
	colname IS NOT NULL

Or, if you're in MySQL >= 5.0.2 and are using true boolean values:

	colname IS TRUE

or, if you just want to check if it's TRUE or UNKNOWN:

	colname IS NOT FALSE


Jasper

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


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux