>>>> 2012/07/26 06:52 +0530, Dhaval Jaiswal >>>>
SELECT * FROM test INTO OUTFILE '/home/test.csv' FIELDS TERMINATED BY ',' ENCLOSED BY '"'
LINES TERMINATED BY '\n'
as above give your join condition before INTO OUTFILE.
Right: MySQL server writes into some directory where it is, not where MySQL client is. If
less than a full path name is given, almost certainly the server will attempt to write
into a directory to which it has no permission, and almost certainly also not into one
that you want it to write into. If server and client run on separate machines with
separate disks, there is no means through OUTFILE of there setting the output where the
client is, only through client s standard output, where you get no choice of field
separator, line separator, or field-quote character (there is none), although you can keep
or skip the column names (-N for skipping them), and suppress the one-character escape
character (-r), same as FIELDS ESCAPED BY ''. There is no means of skipping "NULL" or "\N"
for nulls, which is not CSV format.
And if your MySQL is under Windows, be sure to read all instructions about entering full
pathnames. It is best to avoid the backslash (\), because that is a C-escape introduced
(along with much other C-stuff) into SQL s original PL1.