List:General Discussion« Previous MessageNext Message »
From:Jerry Schwartz Date:January 26 2009 4:02pm
Subject:RE: Help with formatting of 1:n relationship
View as plain text  

>-----Original Message-----
>From: blue.trapezius@stripped [mailto:blue.trapezius@stripped] On
>Behalf Of Vikram Vaswani
>Sent: Monday, January 26, 2009 7:02 AM
>To: mysql@stripped
>Subject: Help with formatting of 1:n relationship
>
>Hello all
>
>I have a database with a 1:n relationship as follows:
>
>Item (1)
>----
>fld1
>fld2
>...
>
>Item_info (n)
>---------
>fld1
>fld2
>...
>
>My client wants me to export these linked records into an Excel file in
>the following format.
>
>item.fld1 item.fld2 ... item_info.fld1 item_info.fld2 ...
>item_info.fld1 item_info.fld2 ..
>
>ie. each item and all the records that make up its info together in a
>single Excel row.
>
>I'm using an excel library that accepts a SELECT as input and generates
>an XLS file with the records as output. I'd like to use this where
>possible. However I don't know if it's possible to write a SELECT that
>compresses a 1:n relationship into a single row. Is this possible, and
>if yes, could someone show me how? Or could you suggest another way in
>which I could achieve the above required output?
>
[JS] I do something similar with a GROUP BY and GROUP_CONCAT(), but that
would put all of your "n"s into one field. In my case, that's what I want;
but it doesn't exactly solve yours because MySQL doesn't seem to have an
"explode" function.

Does whatever tool you are using have any place where you can manipulate the
data between the SELECT and the creation of the XLS? If not,I think you need
a user-defined function for this, or perhaps you can do it with a
user-defined procedure.

Probably someone has a better idea.

>Thanks,
>
>Vikram
>
>--
>Operator: "So what do you need? Besides a miracle."
>Neo: "Guns. Lots of guns."
>     -- The Matrix
>
>--
>MySQL General Mailing List
>For list archives: http://lists.mysql.com/mysql
>To unsubscribe:    http://lists.mysql.com/mysql?unsub=1
>infoshop.com




Thread
Help with formatting of 1:n relationshipVikram Vaswani26 Jan
  • RE: Help with formatting of 1:n relationshipJerry Schwartz26 Jan
    • Re: Help with formatting of 1:n relationshipVikram Vaswani26 Jan
      • Re: Help with formatting of 1:n relationshipBaron Schwartz26 Jan
        • Re: Help with formatting of 1:n relationshipVikram Vaswani26 Jan
        • Re: Help with formatting of 1:n relationshipClaudio Nanni27 Jan
          • Re: Help with formatting of 1:n relationshipWalter Heck27 Jan
      • RE: Help with formatting of 1:n relationshipJerry Schwartz26 Jan