Re: how to check for null in string
In SQL, the correct syntax is IS NULL or IS NOT NULL. Random programming languages more often than not have no decent support for NULL content, although your DB library might have an isnull() function or something similar. Once you've exported a field into a regular variable, however, most often NULL becomes indistinguishable from an emtpy string. On Tue, Feb 17, 2009 at 2:47 AM, PJ af.gour...@videotron.ca wrote: I know this is not working, but how can I check for NULL; or how can I configure my field sub_title so I can check if $booksub_title contains anything or is empty. This problem as been breaking my back...don't know what to put in as a default to be able to check against string input (VARCHAR) or should I use another type? if ($booksub_title != NULL) { echo td width='400'b$booktitle[$i]/bbr $booksub_title[$i]/b; } else {echo td width='400'b$booktitle[$i]/b; } -- Phil Jourdan --- p...@ptahhotep.com http://www.ptahhotep.com http://www.chiccantine.com -- MySQL General Mailing List For list archives: http://lists.mysql.com/mysql To unsubscribe:http://lists.mysql.com/mysql?unsub=vegiv...@tuxera.be -- Celsius is based on water temperature. Fahrenheit is based on alcohol temperature. Ergo, Fahrenheit is better than Celsius. QED.
Re: how to check for null in string
Hi ! Johan De Meersman wrote: In SQL, the correct syntax is IS NULL or IS NOT NULL. Random programming languages more often than not have no decent support for NULL content, although your DB library might have an isnull() function or something similar. Once you've exported a field into a regular variable, however, most often NULL becomes indistinguishable from an emtpy string. That is what embedded SQL has indicator variables for: When you select (rather: fetch) database values into host language (say, C, Cobol, Pascal, ...) variables, you have two to receive them: - The host variable for the real value, - and an indicator variable (typically, int). The indicator would be set to -1 for a NULL value, and it might use positive values to denote strings lengths, truncations, or similar things. Jörg -- Joerg Bruehe, MySQL Build Team, joerg.bru...@sun.com Sun Microsystems GmbH, Sonnenallee 1, D-85551 Kirchheim-Heimstetten Geschaeftsfuehrer: Thomas Schroeder, Wolfgang Engels, Dr. Roland Boemer Vorsitzender des Aufsichtsrates: Martin Haering Muenchen: HRB161028 -- MySQL General Mailing List For list archives: http://lists.mysql.com/mysql To unsubscribe:http://lists.mysql.com/mysql?unsub=arch...@jab.org
Re: how to check for null in string
Johan De Meersman wrote: In SQL, the correct syntax is IS NULL or IS NOT NULL. Random programming languages more often than not have no decent support for NULL content, although your DB library might have an isnull() function or something similar. Once you've exported a field into a regular variable, however, most often NULL becomes indistinguishable from an emtpy string. On Tue, Feb 17, 2009 at 2:47 AM, PJ af.gour...@videotron.ca wrote: I know this is not working, but how can I check for NULL; or how can I configure my field sub_title so I can check if $booksub_title contains anything or is empty. This problem as been breaking my back...don't know what to put in as a default to be able to check against string input (VARCHAR) or should I use another type? if ($booksub_title != NULL) { echo td width='400'b$booktitle[$i]/bbr $booksub_title[$i]/b; } else {echo td width='400'b$booktitle[$i]/b; } -- Phil Jourdan --- p...@ptahhotep.com http://www.ptahhotep.com http://www.chiccantine.com -- MySQL General Mailing List For list archives: http://lists.mysql.com/mysql To unsubscribe: http://lists.mysql.com/mysql?unsub=vegiv...@tuxera.be Problem resolved. The hic in this was not the null but rather the variable. I finally understood that the problem in the code was the variable $booksub_title - since it comes up in a loop it is changed on every pass, therefore the string should be $booksub_title[$i] to correspond to the same string in the else statement... this is what works, now: if (empty ($booksub_title[$i])) { echo td width='400'b$booktitle[$i]/bbr; } else {echo td width='400'b$booktitle[$i]/bbr$booksub_title[$i]br; } so there! Thanks all for your input which did help me to see the light, -- Phil Jourdan --- p...@ptahhotep.com http://www.ptahhotep.com http://www.chiccantine.com -- MySQL General Mailing List For list archives: http://lists.mysql.com/mysql To unsubscribe:http://lists.mysql.com/mysql?unsub=arch...@jab.org
how to check for null in string
I know this is not working, but how can I check for NULL; or how can I configure my field sub_title so I can check if $booksub_title contains anything or is empty. This problem as been breaking my back...don't know what to put in as a default to be able to check against string input (VARCHAR) or should I use another type? if ($booksub_title != NULL) { echo td width='400'b$booktitle[$i]/bbr $booksub_title[$i]/b; } else {echo td width='400'b$booktitle[$i]/b; } -- Phil Jourdan --- p...@ptahhotep.com http://www.ptahhotep.com http://www.chiccantine.com -- MySQL General Mailing List For list archives: http://lists.mysql.com/mysql To unsubscribe:http://lists.mysql.com/mysql?unsub=arch...@jab.org