List:MySQL on Win32« Previous MessageNext Message »
From:Markus Grossrieder Date:July 1 2008 1:33pm
Subject:Re: group_concat (was: Offtopic help)
View as plain text  
BTW & FYI,

GROUP_CONCAT() was added in MySQL 4.1.

For versions below (Windows), there is Emmanuel Kartmann's UDF
available,

"MyGroupConcat: A MySQL UDF aggregate function for string concatenation"
http://www.codeproject.com/KB/database/mygroupconcat.aspx

Installation notes:
- if your MySQL is not installed in "C:\MySql\bin\", you have to modify
  COMP_SET_VARIABLES.BAT, simply replace the value for
  ADD_DLL_INSTALL_PATH at line 18
- run SETUP.BAT
- once installed, dont forget to declare it in MySQL (on 1 line):
  CREATE AGGREGATE FUNCTION group_concat
    RETURNS STRING SONAME "MyGroupConcat.dll"

Markus


----- Original Message ----- 
From: "Jorge Bastos" <mysql.jorge@stripped>
To: "'Randy Clamons'" <randy@stripped>
Cc: <win32@stripped>
Sent: Monday, June 30, 2008 8:51 PM
Subject: RE: Offtopic help


> Fantastic!
> This is my function!!
> Thanks
>
> Jorge
>
>
>> -----Original Message-----
>> From: Randy Clamons [mailto:randy@stripped]
>> Sent: segunda-feira, 30 de Junho de 2008 18:34
>> To: Jorge Bastos
>> Cc: win32@stripped
>> Subject: Re: Offtopic help
>>
>> Use the GROUP_CONCAT() function. Quote from the manual:
>>
>> GROUP_CONCAT(expr)
>>
>> This function returns a string result with the concatenated non-NULL
>> values from a group. It returns NULL if there are no non-NULL values.
>> The full syntax is as follows:
>>
>> GROUP_CONCAT([DISTINCT] expr [,expr ...]
>>              [ORDER BY {unsigned_integer | col_name | expr}
>>                  [ASC | DESC] [,col_name ...]]
>>              [SEPARATOR str_val])
>>
>> mysql> SELECT student_name,
>>     ->     GROUP_CONCAT(test_score)
>>     ->     FROM student
>>     ->     GROUP BY student_name;
>>
>> Or:
>>
>> Set the separator to ";". You must be using version 5.0 or higher, but
>> since you are talking functions and procedures you probably are.
>>
>> BTW, mySql will not concatenate strings using +. "Select 'first ' +
>> 'second'" returns "0" as the result.
>>
>> Randy Clamons
>> Systems Programming
>> randy@stripped
>>
>>
>>
>> Jorge Bastos wrote:
>> > Hi people,
>> >
>> > I wounder if anyone can give me a hand.
>> >
>> > I want to create a view or function/procedure that returns a string,
>> and
>> > inside that function I have to pass two arguments, and do a SQL
>> statement
>> > like this:
>> >
>> >
>> >
>> > Select * from tbl where field1=art1 and field2=arg2;
>> >
>> > Result=concat(field3 ,';')         <= for each record found I need to
>> > concatenate the result, and return it on the end.
>> >
>> >
>> >
>> > How can this be possible?
>> >
>> >
>> >
>
>
> -- 
> MySQL Windows Mailing List
> For list archives: http://lists.mysql.com/win32
> To unsubscribe:
> http://lists.mysql.com/win32?unsub=1
>


--------------------------------------------------------------------------------



No virus found in this incoming message.
Checked by AVG.
Version: 8.0.101 / Virus Database: 270.4.3/1526 - Release Date: 6/30/2008
8:43 AM

Thread
Offtopic helpJorge Bastos28 Jun
  • RE: Offtopic helpLeif Johnston28 Jun
    • RE: Offtopic helpJorge Bastos28 Jun
  • RE: Offtopic helpJohn Bonnett30 Jun
  • Re: Offtopic helpRandy Clamons30 Jun
    • RE: Offtopic helpJorge Bastos30 Jun
  • Re: group_concat (was: Offtopic help)Markus Grossrieder1 Jul