MySQL Forums
Forum List  »  Newbie

Re: Converting result set into string
Posted by: Stefan Tister
Date: October 09, 2009 03:52AM

works in principle but....

i have documents in different categories (catID) and would know how much documents are total in the category of the specified document per day and user. so i would like to add a field in which the sum of the documents are sepreated.

i.e.

catID = 1 ---> 4 docs
catID = 2 ---> 2 docs
catID = 3 ---> 6 docs

so the output should look like:
1-4;2-2;3-6

the following test gives me an "Invalid use of group function"

select group_concat(concat_ws('-', tbl.catID, count(tbl.catID)) separator ';') from documents tbl
where tbl.userID = 27345
AND year(tbl.docdate) = '2009'
AND month(tbl.docdate) = '10'
AND day(tbl.docdate) = '06'
group by tbl.catID;


any other idea?


Chad Bourque Wrote:
-------------------------------------------------------
> Stefan,
>
> Try this:
>
> update tableA set
> colA = (select group_concat(concat_ws(',',
> colA, colB, colC) separator ';')
> from taableB
> where id < 10)
> where id = 1;
>
> HTH,
> Chad

Options: ReplyQuote


Subject
Written By
Posted
Re: Converting result set into string
October 09, 2009 03:52AM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.