Reputation: 555
mysqldump -t -u root -p mytestdb mytable --where=datetime LIKE '2014-09%'
This is what I am doing and it returns:
mysqldump: Couldn't find table: "LIKE"
I am trying to return all the rows where the column datetime
is like 2014-09
meaning "all September rows".
Upvotes: 37
Views: 61414
Reputation: 602
You missed "" for where clause . datetime column name datetime is not recommended. It is a data type as well.
mysqldump -u root -p mytestdb mytable --where="datetime LIKE '2014-09%'
" > mytable.sql;
After executing the command a prompt will ask for MySQL password. then check your current folder for generated mystable.sql
Upvotes: 0
Reputation: 444
Not the answer but just a notice, when using mysqldump
it will automatically add DROP TABLE
and CREATE TABLE
to the export file, in case you don't want that add --skip-add-drop-table
and --no-create-info
with the command, like:
mysqldump -u root-p database_name table_name --skip-add-drop-table --no-create-info > export.sql
Upvotes: 1
Reputation: 184
Selecting dates using LIKE is not a good idea. I saw this method in one project. This causes huge DBMS load and slow system operation as no index by this table column used.
If you need to select date range use between:
where datetime between '2014-09-01' and '2014-09-30 23:59:59'
Upvotes: 5
Reputation: 8406
You may need to use quotes:
mysqldump -t -u root -p mytestdb mytable --where="datetime LIKE '2014-09%'"
Upvotes: 73