Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 899
  • Last Modified:

unexpected EOF Error In mysql

********************** Named as test.sh ***************************
#!/bin/sh
mysql -uroot -e "USE Userdata;

SELECT 'Name', 'ID', 'Mobile',UNION
SELECT Name,Id,Mobile from Mobiledata INTO OUTFILE '/tmp/Test_REPORT-22-08-2012.csv' FIELDS TERMINATED BY ',' ENCLOSED BY '"';"

exit 0
*******************

###############Error I am Getting While executing ##################
./test.sh: line 5: unexpected EOF while looking for matching `''
./test.sh: line 8: syntax error: unexpected end of file
0
gunasekharyalamuri
Asked:
gunasekharyalamuri
  • 3
  • 2
1 Solution
 
Guy Hengel [angelIII / a3]Billing EngineerCommented:
you have a "," too much before UNION
also, you should use UNION ALL to avoid a implicit DISTINCT operation
finally, the ENCLOSED BY looks bad, your single quotes are mislocated indeed.

SELECT 'Name', 'ID', 'Mobile' UNION ALL
SELECT Name,Id,Mobile from Mobiledata INTO OUTFILE '/tmp/Test_REPORT-22-08-2012.csv' FIELDS TERMINATED BY ',' ENCLOSED BY '";"'

Open in new window

0
 
gunasekharyalamuriAuthor Commented:
Getting Same Error..
0
 
Guy Hengel [angelIII / a3]Billing EngineerCommented:
I see now, the ; and " and ' are because of the sh script ...

#!/bin/sh
mysql -uroot -DUserdata -e "SELECT 'Name', 'ID', 'Mobile' UNION ALL SELECT Name,Id,Mobile from Mobiledata INTO OUTFILE '/tmp/Test_REPORT-22-08-2012.csv' FIELDS TERMINATED BY ',' ENCLOSED BY '"'

exit 0

Open in new window

0
 
gunasekharyalamuriAuthor Commented:
Sorry Same Problem, Please tell me alternate..
0
 
Guy Hengel [angelIII / a3]Billing EngineerCommented:
I don't see any problem ... so I cannot tell a alternate at this point ...
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

  • 3
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now