Link to home
Start Free TrialLog in
Avatar of Putoch
PutochFlag for Afghanistan

asked on

Exporting Mysql resutlts into one colunm

i have results sets like this:
customre  historytext
123           this is an example line, this is another example line, this is the third example line.

What i would like is this

Customer  historytext                           historytext                               historytext
123           this is an example line         this is aother example line         this is the third example line



So that every time on my org example, when there is a comma in the history text, it would move this text into the next cell.
I do not want to write the code usiing the MAX is null expression, as i don't know how many colunmss could be on any one customer, they all vary

Is this possible.

I am using Mysql and had been using the Group_concat function to group all text into one cell.
however when i export it this data will not all show on the cell because of the limits on excel.

Can anyone please help?
ASKER CERTIFIED SOLUTION
Avatar of lcohan
lcohan
Flag of Canada image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Putoch

ASKER

I tried exporting to CSV but it changes the format of the file and dliminates the text into rows , i have tried to stop this but can not.
The history_text is a mix of 3 actual fields from the db.
They are a timestamp  & varchar data types.

SELECT customer_id, Group_Concat(date_entered,' : ',enteredby,' : ',history_text, ' // ')as HISTORY
FROM ....

Avatar of Putoch

ASKER

When i export it to csv it exports it into rows instead of into colunms
Avatar of dbadmin78
dbadmin78

Try this:

SELECT customer_id,rtrim(convert(char,date_entered))+','+rtrim(convert(char,enteredby))+','+rtrim(convert(char,history_text))+',' as HISTORY

from yourtablename

I think Excel doesn't see the colon as a delimiter...If that works and you need help with the date format, I have more code for that :)
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Putoch

ASKER

It was on the configuration section of the SQLYOG export tool.

Escaped by: \
Lines Terminated by: \n

Fields
Variable Lenghts
Fields Terminated by: ,


When i reconfigured the settings it worked out perfectly.
Avatar of Putoch

ASKER

thanks everyone for their advice
I believe the following solved the problem:
It was on the configuration section of the SQLYOG export tool.

Escaped by: \
Lines Terminated by: \n

Fields
Variable Lenghts
Fields Terminated by: ,


When i reconfigured the settings it worked out perfectly.