newbie
newbie

Reputation: 147

ERROR at line 1: Unknown command '\ '

When I run the SQL script to export data out of MySQL database, using command line, I get the above error. The SQL query works fine when run in phpMyAdmin, but just when run from command line throws an error.

Here is the command line I am using:

cat my_export | mysql -uxyzuser -pabcpassword mydb > export072911.txt

The code in my_export is as follows:

SELECT CONCAT( custfirstname, ' ', custlastname ) AS fullname, custcompany, \
SPACE( 10 ) AS custtitle, custaddressone, custaddresstwo, custcity, custstate, \
custzip, SPACE( 10 ) AS dummy, custphone, SPACE( 10 ) AS custfax, custemail, \
event_id, SPACE( 10 ) AS ticket1, SPACE( 10 ) AS ticket2, \
SPACE( 10 ) AS ticket3, SPACE( 10 ) AS ticket4, orderdate, b.quantity, \
FROM order_master a \
LEFT JOIN order_detail b ON b.order_master_id = a.id \
LEFT JOIN customer c ON c.email = a.custemail \
WHERE a.orderdate > '2010-12-01'\
AND a.event_id = '30' \
AND a.orderstatus = 'O' \
AND b.litype = 'ITEM' \
AND b.reftag = 'PKG' \
ORDER BY a.orderdate DESC;

Upvotes: 3

Views: 10889

Answers (1)

Michael Berkowski
Michael Berkowski

Reputation: 270767

You can safely delete all the backslashes and use input redirection rather than piping. The backslashes are needed if you are working with the SQL as a shell variable, but not for piping or redirection.

mysql -uxyzuser -pabcpassword mydb < my_export > export072911.txt

UPDATE After a quick test of my own, it looks like the pipe works just as well as input redirection as long as the backslashes are removed.

Upvotes: 4

Related Questions