Extract from MySQL to csv-file

This is a discussion on Extract from MySQL to csv-file within the PHP Language forums, part of the PHP Programming Forums category; I need to output data from a number of MySQL tables in a csv-format where I first have a ...


Go Back   Usenet Forums > PHP Programming Forums > PHP Language

FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 08-23-2004
John Jessen
 
Posts: n/a
Default 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


Reply With Quote
  #2 (permalink)  
Old 08-23-2004
Marcin Dobrucki
 
Posts: n/a
Default Re: Extract from MySQL to csv-file

John Jessen wrote:
> 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.


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
Reply With Quote
  #3 (permalink)  
Old 08-23-2004
John Jessen
 
Posts: n/a
Default Re: Extract from MySQL to csv-file


"Marcin Dobrucki" <Marcin.Dobrucki@TAKETHISAWAY.nokia.com> skrev i en
meddelelse news:VOkWc.23505$k4.455801@news1.nokia.com...
> John Jessen wrote:
> > 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.

>
> 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


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


Reply With Quote
  #4 (permalink)  
Old 08-23-2004
Chris Hope
 
Posts: n/a
Default Re: Extract from MySQL to csv-file

John Jessen wrote:

>
> "Marcin Dobrucki" <Marcin.Dobrucki@TAKETHISAWAY.nokia.com> skrev i en
> meddelelse news:VOkWc.23505$k4.455801@news1.nokia.com...
>> John Jessen wrote:
>> > 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.

>>
>> 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

>
> 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!


http://www.phpmyadmin.net/

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/
Reply With Quote
  #5 (permalink)  
Old 08-24-2004
Al C.
 
Posts: n/a
Default Re: Extract from MySQL to csv-file

John Jessen wrote:

> 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.


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.)
***
Reply With Quote
Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are Off
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT +1. The time now is 09:12 AM.


Powered by vBulletin® Version 3.7.3
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO 3.0.0