Putoch
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?
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
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
When i export it to csv it exports it into rows instead of into colunms
Try this:
SELECT customer_id,rtrim(convert( char,date_ entered))+ ','+rtrim( convert(ch ar,entered by))+','+r trim(conve rt(char,hi story_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 :)
SELECT customer_id,rtrim(convert(
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
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
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.
Escaped by: \
Lines Terminated by: \n
Fields
Variable Lenghts
Fields Terminated by: ,
When i reconfigured the settings it worked out perfectly.
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.
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.
ASKER
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,
FROM ....