Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to export a specific column data in MySQL

Tags:

mysql

I have a table. I need to export all the rows for 1 column only. How can I achieve this? I know how to export the whole table but have not find a way to export a single columns data.

like image 343
Jury A Avatar asked Jul 24 '12 12:07

Jury A


People also ask

How do I fetch a specific column in MySQL?

If you want to select only specific columns, replace the * with the names of the columns, separated by commas. The following statement selects just the name_id, firstname and lastname fields from the master_name table.

How do I export a selected column in PHPMyAdmin?

Show activity on this post. open the table from which you want to export only certain column , click on structure , tick mark on check box of that column , click on browse button ! after that it will show you your column data , below their is written export button click on it !

How do I export a column?

Select Miscellaneous > File Export > General or Configuration > External > Export Files to access the Export File List screen. Select the export from the list and select the Edit button to access the Export File Details screen. Select the Export Columns button. The Export Column Details screen appears.

How do I select a specific record in MySQL?

MySQL SELECT statement is used to retrieve rows from one or more tables. The statement can also include UNION statements and subqueries. SELECT statement is used to fetch rows or records from one or more tables.


2 Answers

This query should work(Use SELECT INTO OUTFILE 'file_name')-

SELECT `column` FROM `table` INTO OUTFILE 'file_name'

Refer this.

like image 70
Jacob Avatar answered Sep 23 '22 17:09

Jacob


You can do it very easily using MySQL GUI tools like SQLyog, PHPMyAdmin. In SQLyog you just need to select the table, Click on "Export As..." Icon and you will get dialog to select the columns that you want to Export. Then click on "Export Button". Export is done...

Here is the screen shot showing export of column "city" in XML format.

Hope it helps...

SQLyog Export As Screenshot

like image 26
jsist Avatar answered Sep 23 '22 17:09

jsist