[SOLVED] mysqldump from a query

Issue

How can I make a mysql dump for table from a query?

I need something like this..

mysqldump -uroot -pxxxx mydb "select * from table where name='1';" >  /tmp/a

Thanks.

Solution

mysqldump has a --where parameter: Manual

Dump only rows selected by the given WHERE condition. Quotes around the condition are mandatory if it contains spaces or other characters that are special to your command interpreter.

Examples:

–where="user=’jimf’"

-w"userid>1"

-w"userid<1"

I don’t know what they use, but phpMyAdmin can do this too, Just make the query, select all rows and choose the "export" button to the bottom.

Answered By – Pekka

Answer Checked By – Dawn Plyler (BugsFixing Volunteer)

Leave a Reply

Your email address will not be published.