Extract from MySQL to csv-file

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • John Jessen

    Extract from MySQL to csv-file

    I need to output data from a number of MySQL tables in a csv-format where I
    first have a header line, then a number of order lines, a new header line,
    etc.

    What I need is advise on a tool to do this for me, as I assume this is not
    possible with for examle MS-Access ?

    Will a tool like EMS MySQL Query be of any use? Should mention that I am
    absolutely not a programmer, but can use php-myadmin, MS-Access etc.

    Thanks.

    John


  • Marcin Dobrucki

    #2
    Re: Extract from MySQL to csv-file

    John Jessen wrote:[color=blue]
    > I need to output data from a number of MySQL tables in a csv-format where I
    > first have a header line, then a number of order lines, a new header line,
    > etc.[/color]

    You are banging on the wrong door. This is a PHP group, not MySQL.
    But anyway, what you want can be acomplished with:

    SELECT .... FROM ... INTO OUTFILE '/tmp/somefile.csv' FIELDS
    TERMINATED BY ',';

    /Marcin

    Comment

    • John Jessen

      #3
      Re: Extract from MySQL to csv-file


      "Marcin Dobrucki" <Marcin.Dobruck i@TAKETHISAWAY. nokia.com> skrev i en
      meddelelse news:VOkWc.2350 5$k4.455801@new s1.nokia.com...[color=blue]
      > John Jessen wrote:[color=green]
      > > I need to output data from a number of MySQL tables in a csv-format[/color][/color]
      where I[color=blue][color=green]
      > > first have a header line, then a number of order lines, a new header[/color][/color]
      line,[color=blue][color=green]
      > > etc.[/color]
      >
      > You are banging on the wrong door. This is a PHP group, not MySQL.
      > But anyway, what you want can be acomplished with:
      >
      > SELECT .... FROM ... INTO OUTFILE '/tmp/somefile.csv' FIELDS
      > TERMINATED BY ',';
      >
      > /Marcin[/color]

      Marcin, you are right, but I could not find a MySQL group :-(
      Re your suggestion, please note that I need two different type of lines in
      the file: Header-lines and Order-lines. They have different content, and is
      this fact that give me worries. MS-Access is a tabular way of doing things,
      so I look for a tool that could generate the needed output. Certainly it
      could be accomplished by PHP/SQL, but that exceeds my skills!

      John


      Comment

      • Chris Hope

        #4
        Re: Extract from MySQL to csv-file

        John Jessen wrote:
        [color=blue]
        >
        > "Marcin Dobrucki" <Marcin.Dobruck i@TAKETHISAWAY. nokia.com> skrev i en
        > meddelelse news:VOkWc.2350 5$k4.455801@new s1.nokia.com...[color=green]
        >> John Jessen wrote:[color=darkred]
        >> > I need to output data from a number of MySQL tables in a csv-format[/color][/color]
        > where I[color=green][color=darkred]
        >> > first have a header line, then a number of order lines, a new header[/color][/color]
        > line,[color=green][color=darkred]
        >> > etc.[/color]
        >>
        >> You are banging on the wrong door. This is a PHP group, not MySQL.
        >> But anyway, what you want can be acomplished with:
        >>
        >> SELECT .... FROM ... INTO OUTFILE '/tmp/somefile.csv' FIELDS
        >> TERMINATED BY ',';
        >>
        >> /Marcin[/color]
        >
        > Marcin, you are right, but I could not find a MySQL group :-(
        > Re your suggestion, please note that I need two different type of lines in
        > the file: Header-lines and Order-lines. They have different content, and
        > is this fact that give me worries. MS-Access is a tabular way of doing
        > things, so I look for a tool that could generate the needed output.
        > Certainly it could be accomplished by PHP/SQL, but that exceeds my skills![/color]



        You export the table as a CSV and there's an option to include the field
        names in the first row, if that's what you are meaning. If you're wanting
        to get data from one table for the first line, and then another table for
        the rest of the file then you are going to have to write some code. Either
        that or get the MySQL ODBC driver and link Access as a front end into
        MySQL. http://www.mysql.com/products/connector/odbc/

        --
        Chris Hope - The Electric Toolbox - http://www.electrictoolbox.com/

        Comment

        • Al C.

          #5
          Re: Extract from MySQL to csv-file

          John Jessen wrote:
          [color=blue]
          > I need to output data from a number of MySQL tables in a csv-format where I
          > first have a header line, then a number of order lines, a new header line,
          > etc.[/color]

          If you are writing a PHP program you might think about using the ADODB
          Database wrapper. (They moved the site so you have to google for it.) This
          comes with some very nice tools, one of which lets you do what you want.

          If you want to see a good example go to: http://www.jaya123.com

          Click the "demo' button on right side of screen (in red)
          Enter 'demo' and 'demo' and click the green check mark
          Click Report Menu on left side of screen
          Click "Customer by Demographics link at top of screen
          In blue criteria screen scoll down and check "headers" and "table"

          I think this is exactly what you will want. If you need help in getting this,
          let me know.

          Al Canton
          Adams-Blake Company, Inc.
          ***
          JAYA123 - the web-based total-office system for the
          small biz. Order entry, billing, bookkeeping, etc. for $14.95
          a month. Everyone says "It's cool as a moose!!"
          See why at:http://www.jaya123.com ('ja-eye-ah' means
          'victory' in Sanskrit.)
          ***

          Comment

          Working...