If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Database Server Software > MySQL > NULL values to '' widthin GROUP BY processing

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 11-03-04, 08:55
Markus123 Markus123 is offline
Registered User
 
Join Date: Nov 2004
Posts: 14
Red face NULL values to '' widthin GROUP BY processing

Hi,

I have some left outer joins. The data within the fields is always of varchar or integer type. Querying the data will never send back NULL-values, because the default value of strings is set to an empty string. But in my outer joins there appear NULL-values.

The queries have to support a Pervasive DB and my MySQL DB. The Pervasive DB groups NULL values and empty strings to one group, but MySQL doesn't. The result looks like this:

MySQL DB:
+----------+--------+-------+------+---------+--------+
| count(*) | midkey | datum | zeit | midnnam | reskey |
+----------+--------+-------+------+---------+--------+
| 411 | [NULL] | | | [NULL] | [NULL] |
| 2 | [NULL] | | | [NULL] | |
......


Pervasive DB:
+----------+--------+-------+------+---------+--------+
| count(*) | midkey | datum | zeit | midnnam | reskey |
+----------+--------+-------+------+---------+--------+
| 413 | | | | | |
........


So the reskey is grouped by Pervasive to an empty string but not by MySQL. There is a NULL-group and an empty string group.

Does anyone know a possiblity to set NULL values to empty strings in MySQL GROUP BY queries?

Thanks for your help,
Markus
Reply With Quote
  #2 (permalink)  
Old 11-03-04, 09:27
r937 r937 is offline
SQL Consultant
 
Join Date: Apr 2002
Location: Toronto, Canada
Posts: 19,534
use COALESCE(fieldname,'')
__________________
r937.com | rudy.ca
please visit Simply SQL and buy my book
Reply With Quote
  #3 (permalink)  
Old 11-03-04, 09:58
Markus123 Markus123 is offline
Registered User
 
Join Date: Nov 2004
Posts: 14
Talking

Hi,

I'm wondering that COALESCE is accepted in the GROUP BY clause - but it seems to work.

Thank you for your help,
Markus
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On