1

Can you please advise me what I am doing wrong here? My sqldump command is not working correctly as it ?

mysqldump -u jim -p mydb mytable --where mycondition="ERROR-5000-JAVA" > /home/jim/issue1.sql 
Enter password: 
mysqldump: Couldn't execute 'SELECT /*!40001 SQL_NO_CACHE */ * FROM `mytable` WHERE mycondition=ERROR-5000': Unknown column 'ERROR' in 'where clause' (1054)
learner
  • 2,480
  • 10
  • 50
  • 94

1 Answers1

3

You need quotes around the whole --where option, so that the double quotes around the value will be sent to MySQL.

mysqldump -u jim -p mydb mytable --where 'mycondition="ERROR-5000-JAVA"' > /home/jim/issue1.sql 
Barmar
  • 741,623
  • 53
  • 500
  • 612
  • Thanks mate ! works like a charm. I always get confused in mysql when to put "double quotes and when to put ' quotes. Any idea ? This time around I used " after = sign as I got an idea from another thread but didn't work as I had to use ' after --where. Its all confusing .... – learner Nov 24 '16 at 07:28
  • You have to remember that the shell also processes quotes. So if you want MySQL to see the quotes, you have to escape them or wrap them in more quotes. – Barmar Nov 24 '16 at 07:29
  • About your MySQL quote confusion, see http://stackoverflow.com/questions/11321491/when-to-use-single-quotes-double-quotes-and-backticks – Barmar Nov 24 '16 at 07:29