
![]() |
perkiset
I just performed this query:
SELECT CONCAT( fname, '|', lname, '|', email, '|', prime_city, '|', prime_state, '|', prime_zip ) KaptainKrayola
does mysql have a built in function that will swap in another value if the column you are selecting is null? t-sql has one (i think) but the Kaptain can't for the life of him remember what it is just that he had to use it for something once.
another utterly useless post by the Kaptain... ![]() thedarkness
LOL, you too huh Perk, we move in the same circles.....
![]() ![]() This is by design. Use CONCAT_WS() instead or wrap NULLable paremeters with IFNULL() function. I think concat is a mysql construction and not part of SQL (i could easily be wrong) so they can do whatever they bloody well like ;-) Cheers, td perkiset
Never heard of that one... and looking at the MySQL dox it's a clusterPhuque - CONCAT stops evaluation of the job if ANY item is NULL, CONCAT_WS simply ignores any NULLs, but does not kill the entire line. Why the difference? What where they smoking?
And how the HELL did you find that one? ![]() thedarkness
It was in the mysql version of bugzilla
![]() ![]() Reply was the good old "this behaviour is by design, please read the documentation and the docs on submitting bugs"..... it's a "feature" ![]() Have you tried wrapping the paramters with the ifnull() function? using your initial example you would do something like the following; SELECT CONCAT( fname, '|', lname, '|', email, '|', IFNULL(prime_city, 'Joliet'), '|', IFNULL(prime_state, 'Illinois'), '|', IFNULL(prime_zip, '60436' ) FROM contactsWHERE id =1 Cheers, td P.S. Found the initial report that led me on the path to righteousness, amen, yea verily http://bugs.mysql.com/bug. php?id=480KaptainKrayola
ifnull is basically what the Kaptain was getting at above just couldn't remember what it was - thanks TD now we can finally sleep better at night
perkiset
quote author=thedarkness link=topic=115.msg597#msg597 date=1177570923 P.S. Found the initial report that led me on the path to righteousness, amen, yea verily http://bugs.mysql.com/bug. php?id=480![]() Actually, it enraged me off so mightily that I smote down the vile null fields and made them required-default-emptys instead. I have no need for them to be optionally null, so fish it. Works like a charm now ![]() thedarkness
quote author=KaptainKrayola link=topic=115.msg613#msg613 date=1177599324 ifnull is basically what the Kaptain was getting at above just couldn't remember what it was - thanks TD now we can finally sleep better at night ![]() |

Thread Categories

![]() |
![]() |
Best of The Cache Home |
![]() |
![]() |
Search The Cache |
- Ajax
- Apache & mod_rewrite
- BlackHat SEO & Web Stuff
- C/++/#, Pascal etc.
- Database Stuff
- General & Non-Technical Discussion
- General programming, learning to code
- Javascript Discussions & Code
- Linux Related
- Mac, iPhone & OS-X Stuff
- Miscellaneous
- MS Windows Related
- PERL & Python Related
- PHP: Questions & Discussion
- PHP: Techniques, Classes & Examples
- Regular Expressions
- Uncategorized Threads