In this case, mysqldump may be difficult to solve. The following method can be used to solve this problem.
Method 1: Use insert and select in combination
1. Create a new table, such as new-table, containing the name of the field to be exported, such as a, B, and c.
2. Use insert into new-table (a, B, c) select a, B, c from old-table;
3. The remaining step is to export the new table and process the text.
Method 2: use MySQL's select into outfile backup Statement (recommended)
In the following example, a file is generated, and each value is separated by a comma. This format can be used by many programs.
Copy codeThe Code is as follows:
SELECT a, B, a + B INTO OUTFILE '/tmp/result. text'
Fields terminated by ', 'optionally enclosed '"'
Lines terminated by '\ N'
FROM test_table;
For details, see the usage of select.
Copy codeThe Code is as follows: select subject into outlifile '/tmp/xiaoruizi. text' fields terminated by '\ t' optionally enclosed by' "'Lines terminated by '\ n' from pw_blog;
Method 3: Use mysqldump
What's amazing is that I found that mysqldump actually has a very useful parameter "-w"
Instructions in the help document:
Copy codeThe Code is as follows:
-W |-where =
Dump only selected records; QUOTES mandatory!
Can this parameter be used to export some values? For example, if I want to export some data whose id is greater than 2312387:
Copy codeThe Code is as follows: mysqldump-u root-p bbscs6 BBSCS_USERINFO-where "ID> 2312387"> BBSCS_USERINFO-par. SQL