Link to home
Start Free TrialLog in
Avatar of gunasekharyalamuri
gunasekharyalamuri

asked on

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
Avatar of Guy Hengel [angelIII / a3]
Guy Hengel [angelIII / a3]
Flag of Luxembourg image

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

Avatar of gunasekharyalamuri
gunasekharyalamuri

ASKER

Getting Same Error..
ASKER CERTIFIED SOLUTION
Avatar of Guy Hengel [angelIII / a3]
Guy Hengel [angelIII / a3]
Flag of Luxembourg image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Sorry Same Problem, Please tell me alternate..
I don't see any problem ... so I cannot tell a alternate at this point ...