[2 days left] What’s wrong with your cloud strategy? Learn why multicloud solutions matter with Nimble Storage.Register Now

x
?
Solved

Exporting Mysql resutlts into one colunm

Posted on 2011-02-24
7
Medium Priority
?
296 Views
Last Modified: 2012-05-11
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?
0
Comment
Question by:Putoch
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
  • 2
7 Comments
 
LVL 40

Accepted Solution

by:
lcohan earned 1000 total points
ID: 34971072
What is the datatype on the three concatenated columns? It is pretty obvious they are big enough to create a new column something like text perhaps and obviously EXCEL cell won't allow that. Did you tried to export to flat CSV file instead which is different than XLS or XLSX?
0
 

Author Comment

by:Putoch
ID: 34971440
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 ....

0
 

Author Comment

by:Putoch
ID: 34971483
When i export it to csv it exports it into rows instead of into colunms
0
Nothing ever in the clear!

This technical paper will help you implement VMware’s VM encryption as well as implement Veeam encryption which together will achieve the nothing ever in the clear goal. If a bad guy steals VMs, backups or traffic they get nothing.

 

Expert Comment

by:dbadmin78
ID: 34973230
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 :)
0
 

Assisted Solution

by:dbadmin78
dbadmin78 earned 1000 total points
ID: 34973253
Also, if you do need to keep using the GROUP_CONCAT feature, can you add a comma after the colon like so:

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


Excel will read the comma as a delimeter and it won't put it in the text.
0
 

Author Comment

by:Putoch
ID: 35084128
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.
0
 

Author Closing Comment

by:Putoch
ID: 35084139
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.
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In part one, we reviewed the prerequisites required for installing SQL Server vNext. In this part we will explore how to install Microsoft's SQL Server on Ubuntu 16.04.
In this blog, we’ll look at how improvements to Percona XtraDB Cluster improved IST performance.
Viewers will learn how to use the INSERT statement to insert data into their tables. It will also introduce the NULL statement, to show them what happens when no value is giving for any given column.
In this video, Percona Solutions Engineer Barrett Chambers discusses some of the basic syntax differences between MySQL and MongoDB. To learn more check out our webinar on MongoDB administration for MySQL DBA: https://www.percona.com/resources/we…

649 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question