问题
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".
回答1:
You may need to use quotes:
mysqldump -t -u root -p mytestdb mytable --where="datetime LIKE '2014-09%'"
回答2:
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'
来源:https://stackoverflow.com/questions/26261670/mysqldump-with-where-clause-is-not-working