I’m writing this in JAVA :
stmt.executeQuery("SELECT * FROM mytable INTO OUTFILE '/tmp/mytable.csv' FIELDS TERMINATED BY ',' OPTIONALLY ENCLOSED BY '"' ESCAPED BY '\\' LINES TERMINATED BY '\n' ;");
This is has to be written between ” ” as show because It has to be a String. However, when I run the code it says “Unclosed String and Character laterals”. I know, but how to not let the compiler be confused by the ” and ‘ which are part of the inner statement ? I want the compiler to consider them normal Strings not Java operations.
Plz Help!
Escape them with a backslash:
" Hello \"world\"!"I’m not sure if it will help in this particular case, but try a PreparedStatement: it often allows you to not have to worry about quoting of arguments. (I haven’t seen it used for this sort of non-CRUD SQL, so I’m not sure it will help).