Sorry, I should have given you more information about the problem.

We have a Java program, with a J2EE backend which is connected to a MySQL
database.
The database is running on a windows 2000 machine, and we want to output the
contents of the tables in text format(CSV).   I can get the formatting ok,
but it just needs the table headings.

Ideally we want to use one or more queries to do this, rather than using
mysqldump.

-----Original Message-----
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]]
Sent: 10 September 2001 11:38 am
To: Andrew Murphy
Subject: Re: Help needed getting table headings into an outfile


I do this in perl to get the headers.  Perhaps you can adjust to fit into
your output script.

     my $statement = "SELECT * FROM $table";
     my $sth = $dbh->prepare( $statement ) ;
     $sth->execute();
     my $fields = $sth->{NUM_OF_FIELDS};

     for ( my $i = 0 ; $i < $fields ; $i++ ) {

            $name = $sth->{NAME}->[$i] ;
            if ($i == 0) {
              $fldnames = $name ;
            } else {
              $fldnames = $fldnames . "|" . $name ;
            }
     }  # end of for loop
     $sth->finish();

Dirk Van Wie



Andrew Murphy <[EMAIL PROTECTED]> on 09/10/2001 12:33:50 PM
To:   'mysql Mailing List' <[EMAIL PROTECTED]>
cc:
Subject:  Help needed getting table headings into an outfile


Hi,

I keep sending this to the list, but im not sure if anyone else is getting
it.

I hope you can help me with this.
I am using the INTO OUTFILE 'filename' function, to create .CSV output
files
from my queries.
Whenever I do this, the table headings are removed from the output.  Is
there a way to get the table headings displayed in the output file?

Thanks in advance
Andrew

database, sql, query, table
database, sql, query, table
database, sql, query, table



---------------------------------------------------------------------
Before posting, please check:
   http://www.mysql.com/manual.php   (the manual)
   http://lists.mysql.com/           (the list archive)

To request this thread, e-mail <[EMAIL PROTECTED]>
To unsubscribe, e-mail
<[EMAIL PROTECTED]>
Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php




---------------------------------------------------------------------
Before posting, please check:
   http://www.mysql.com/manual.php   (the manual)
   http://lists.mysql.com/           (the list archive)

To request this thread, e-mail <[EMAIL PROTECTED]>
To unsubscribe, e-mail <[EMAIL PROTECTED]>
Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php

Reply via email to