SitePoint Sponsor

User Tag List

Results 1 to 3 of 3

Thread: export to CVS

  1. #1
    SitePoint Guru
    Join Date
    Jul 2003
    Location
    england
    Posts
    823
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)

    Question export to CVS

    When I attempted to Search this Forum, I keep getting a Database Error screen; I figured if I posted this question I would get a prompt answer.

    There's a client who wishes to export a CVS off her CMS to use with a bulk email service like Constant Contact. I'm not familiar with exporting from MySQL a CVS file.

    These are the fields:
    id, name, email

    I noticed that there was this code, but can someone make sense of what this means if this will work within a form off of a CMS?
    SELECT id, name, email INTO OUTFILE '/tmp/result.csv'
    FIELDS TERMINATED BY ',' OPTIONALLY ENCLOSED BY '"'
    ESCAPED BY \\
    LINES TERMINATED BY '\n'
    FROM users WHERE 1

    I understand the SELECT command and the OUTFILE (sort of), but everything else is quite foreign to me.

    I appreciate some insight.

    Thank you!

  2. #2
    Follow Me On Twitter: @djg gold trophysilver trophybronze trophy Dan Grossman's Avatar
    Join Date
    Aug 2000
    Location
    Philadephia, PA
    Posts
    20,578
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    They're specifying the format of the CSV (comma-separated values, not CVS, the pharmacy) file.

    You can find an explanation of those parts of the query on the LOAD DATA INFILE manual page (the syntax is the same for INFILE and OUTFILE):
    http://dev.mysql.com/doc/refman/5.0/en/load-data.html

  3. #3
    SitePoint Guru
    Join Date
    Jul 2003
    Location
    england
    Posts
    823
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    Now there's a sad typo on my part.


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •