MYSQL Dump only certain rows

MysqlSqlMysqldump

Mysql Problem Overview


I am trying to do a mysql dump of a few rows in my database. I can then use the dump to upload those few rows into another database. The code I have is working, but it dumps everything. How can I get mysqldump to only dump certain rows of a table?

Here is my code:


mysqldump --opt --user=username --password=password lmhprogram myResumes  --where=date_pulled='2011-05-23' > test.sql


Mysql Solutions


Solution 1 - Mysql

Just fix your --where option. It should be a valid SQL WHERE clause, like:

--where="date_pulled='2011-05-23'"

You have the column name outside of the quotes.

Solution 2 - Mysql

You need to quote the "where" clause.

Try

mysqldump --opt --user=username --password=password lmhprogram myResumes  --where="date_pulled='2011-05-23'" > test.sql

Solution 3 - Mysql

Use this code for specific table rows, using LIKE condition.

mysqldump -u root -p sel_db_server case_today --where="date_created LIKE '%2018
%'" > few_rows_dump.sql

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionShattuckView Question on Stackoverflow
Solution 1 - MysqlAJ.View Answer on Stackoverflow
Solution 2 - MysqlNeville KuytView Answer on Stackoverflow
Solution 3 - MysqlRokonz ZazView Answer on Stackoverflow