2

I have a table in my MySQL database which includes HTML code. I can export this table via CSV and get a CSV file from this datatable. Problem is that the HTML code from one column gets spread over multiple rows because of the HTML code which includes line breaks I suppose, these line-breaks are actually used in the CSV file.

Is there an option to make sure that one column stays in one column and not gets spread over multiple rows if there is an enter or linebreak in the code?

4
  • How do you export the data from MySQL? Commented Apr 12, 2017 at 9:15
  • Via export table as CSV, but I think I need a query to make sure the data in the HTML column stays in one column Commented Apr 12, 2017 at 9:16
  • This is functionality built into whatever GUI your are using. If you want to do this via the GUI, then you need to let us know what GUI you are using and attach a screenshot of the export window (if there is any). Most GUI's use a couple of standard options around fields being enclosed and certain characters being escaped. These are the options you need in an sql statement as well Commented Apr 12, 2017 at 9:23
  • I'm using PHYMyAdmin, and I just use the quick export option Commented Apr 12, 2017 at 10:17

1 Answer 1

1

Well, do not use the quick option, use the custom option and set the Columns enclosed with setting to " and Columns escaped with setting to \.

This is going to cause mysql to export the html field enclosed by " character and any line breaks and other special characters within the field values will be escaped and therefore will not cause issues when you try to import the same data.

Obviously, when you try to import the data, you need to set the enclosed by and escaped by parameters again to get it right.

Se mysql documentation on load data infile for more details. I know that load data is for importing and not exporting, but these settings are described there in the mysql manual. The section on export actually points to this location for the detailed settings.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.