export result from select statement

Hi guys,
I wonder how to store to csv or txt file result from SELECT query?
not a whole table nor database. Just results from SELECT query.
Usually I use MySQL Query Browser and Export feature, but in this
case I don't have access with MySQL Query Browser. Though, I have a
command line access.
I found on one place something like
#SELECT 2+2 into outfile '/path/to/specific/directory/test.csv';
Though, it doesn't work?!?

Thanks.

--
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe: http://lists.mysql.com/mysql?unsub=gcdmg-mysql-2 [at] m.gmane.org
LAMP [ So, 09 Januar 2011 00:04 ] [ ID #2052766 ]

Re: export result from select statement

select into outfile is the correct way. What do you mean by doesn't
work? Does it give you an error?

On Sat, Jan 8, 2011 at 3:04 PM, LAMP <lamp [at] afan.net> wrote:
> Hi guys,
> I wonder how to store to csv or txt file result from SELECT query? not a
> whole table nor database. Just results from SELECT query.
> Usually I use MySQL Query Browser and Export feature, but in this case I
> don't have access with MySQL Query Browser. Though, I have a command line
> access.
> I found on one place something like
> #SELECT 2+2 into outfile '/path/to/specific/directory/test.csv';
> Though, it doesn't work?!?
>
> Thanks.
>
> --
> MySQL General Mailing List
> For list archives: http://lists.mysql.com/mysql
> To unsubscribe: =A0 =A0http://lists.mysql.com/mysql?unsub=3Deric.bergen [at] g=
mail.com
>
>



--
Eric Bergen
eric.bergen [at] gmail.com
http://www.ebergen.net

--
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe: http://lists.mysql.com/mysql?unsub=3Dgcdmg-mysql-2 [at] m.gmane.o rg
Eric Bergen [ So, 09 Januar 2011 00:35 ] [ ID #2052767 ]

RE: export result from select statement

The technique I've settled on is this:

mysql blah blah blah < the_select_query.sql > the_output_i_want.txt

That gives you a tab-delimited text file with column headings.

Regards,

Jerry Schwartz
Global Information Incorporated
195 Farmington Ave.
Farmington, CT 06032

860.674.8796 / FAX: 860.674.8341
E-mail: jerry [at] gii.co.jp
Web site: www.the-infoshop.com

>-----Original Message-----
>From: LAMP [mailto:lamp [at] afan.net]
>Sent: Saturday, January 08, 2011 6:05 PM
>To: mysql [at] lists.mysql.com
>Subject: export result from select statement
>
>Hi guys,
>I wonder how to store to csv or txt file result from SELECT query?
>not a whole table nor database. Just results from SELECT query.
>Usually I use MySQL Query Browser and Export feature, but in this
>case I don't have access with MySQL Query Browser. Though, I have a
>command line access.
>I found on one place something like
>#SELECT 2+2 into outfile '/path/to/specific/directory/test.csv';
>Though, it doesn't work?!?
>
>Thanks.
>
>--
>MySQL General Mailing List
>For list archives: http://lists.mysql.com/mysql
>To unsubscribe: http://lists.mysql.com/mysql?unsub=jerry [at] gii.co.jp





--
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe: http://lists.mysql.com/mysql?unsub=gcdmg-mysql-2 [at] m.gmane.org
Jerry Schwartz [ So, 09 Januar 2011 20:44 ] [ ID #2052770 ]

Re: export result from select statement

I second Jerry's recommendation. It always works like a charm for me.

- michael dykman

On Sun, Jan 9, 2011 at 2:44 PM, Jerry Schwartz <jerry [at] gii.co.jp> wrote:
> The technique I've settled on is this:
>
> mysql blah blah blah < the_select_query.sql > the_output_i_want.txt
>
> That gives you a tab-delimited text file with column headings.
>
> Regards,
>
> Jerry Schwartz
> Global Information Incorporated
> 195 Farmington Ave.
> Farmington, CT 06032
>
> 860.674.8796 / FAX: 860.674.8341
> E-mail: jerry [at] gii.co.jp
> Web site: www.the-infoshop.com
>
>>-----Original Message-----
>>From: LAMP [mailto:lamp [at] afan.net]
>>Sent: Saturday, January 08, 2011 6:05 PM
>>To: mysql [at] lists.mysql.com
>>Subject: export result from select statement
>>
>>Hi guys,
>>I wonder how to store to csv or txt file result from SELECT query?
>>not a whole table nor database. Just results from SELECT query.
>>Usually I use MySQL Query Browser and Export feature, but in this
>>case I don't have access with MySQL Query Browser. Though, I have a
>>command line access.
>>I found on one place something like
>>#SELECT 2+2 into outfile '/path/to/specific/directory/test.csv';
>>Though, it doesn't work?!?
>>
>>Thanks.
>>
>>--
>>MySQL General Mailing List
>>For list archives: http://lists.mysql.com/mysql
>>To unsubscribe: =A0 =A0http://lists.mysql.com/mysql?unsub=3Djerry [at] gii.co.=
jp
>
>
>
>
>
> --
> MySQL General Mailing List
> For list archives: http://lists.mysql.com/mysql
> To unsubscribe: =A0 =A0http://lists.mysql.com/mysql?unsub=3Dmdykman [at] gmail=
..com
>
>



--
=A0- michael dykman
=A0- mdykman [at] gmail.com

=A0May the Source be with you.

--
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe: http://lists.mysql.com/mysql?unsub=3Dgcdmg-mysql-2 [at] m.gmane.o rg
Michael Dykman [ So, 09 Januar 2011 21:01 ] [ ID #2052771 ]

Re: export result from select statement

--------------090704070908030402090709
Content-Type: text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding: 7bit

Eric Bergen wrote:
> select into outfile is the correct way. What do you mean by doesn't
> work? Does it give you an error?
>
It was an issue with permissions :-)

Thanks

> On Sat, Jan 8, 2011 at 3:04 PM, LAMP <lamp [at] afan.net> wrote:
>
>> Hi guys,
>> I wonder how to store to csv or txt file result from SELECT query? not a
>> whole table nor database. Just results from SELECT query.
>> Usually I use MySQL Query Browser and Export feature, but in this case I
>> don't have access with MySQL Query Browser. Though, I have a command line
>> access.
>> I found on one place something like
>> #SELECT 2+2 into outfile '/path/to/specific/directory/test.csv';
>> Though, it doesn't work?!?
>>
>> Thanks.
>>
>> --
>> MySQL General Mailing List
>> For list archives: http://lists.mysql.com/mysql
>> To unsubscribe: http://lists.mysql.com/mysql?unsub=eric.bergen [at] gmail.com
>>
>>
>>
>
>
>
>


--------------090704070908030402090709--
LAMP [ Mo, 10 Januar 2011 03:42 ] [ ID #2052801 ]

Re: export result from select statement

--------------060308010105020200080501
Content-Type: text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding: 7bit

maybe it's "clear" to other but it's pretty unclear.
#mysql -username -p "select * from table_name where id=123" >
'/home/me/test/test.txt'
actually doesn't work?!?



Jerry Schwartz wrote:
> The technique I've settled on is this:
>
> mysql blah blah blah < the_select_query.sql > the_output_i_want.txt
>
> That gives you a tab-delimited text file with column headings.
>
> Regards,
>
> Jerry Schwartz
> Global Information Incorporated
> 195 Farmington Ave.
> Farmington, CT 06032
>
> 860.674.8796 / FAX: 860.674.8341
> E-mail: jerry [at] gii.co.jp
> Web site: www.the-infoshop.com
>
>
>> -----Original Message-----
>> From: LAMP [mailto:lamp [at] afan.net]
>> Sent: Saturday, January 08, 2011 6:05 PM
>> To: mysql [at] lists.mysql.com
>> Subject: export result from select statement
>>
>> Hi guys,
>> I wonder how to store to csv or txt file result from SELECT query?
>> not a whole table nor database. Just results from SELECT query.
>> Usually I use MySQL Query Browser and Export feature, but in this
>> case I don't have access with MySQL Query Browser. Though, I have a
>> command line access.
>> I found on one place something like
>> #SELECT 2+2 into outfile '/path/to/specific/directory/test.csv';
>> Though, it doesn't work?!?
>>
>> Thanks.
>>
>> --
>> MySQL General Mailing List
>> For list archives: http://lists.mysql.com/mysql
>> To unsubscribe: http://lists.mysql.com/mysql?unsub=jerry [at] gii.co.jp
>>
>
>
>
>
>
>


--------------060308010105020200080501--
LAMP [ Mo, 10 Januar 2011 03:45 ] [ ID #2052802 ]

Re: export result from select statement

--001517479648202863049977a84c
Content-Type: text/plain; charset=ISO-8859-1

#mysql -username -p -e "select * from table_name where id=123" >
'/home/me/test/test.txt'


On Mon, Jan 10, 2011 at 8:15 AM, LAMP <lamp [at] afan.net> wrote:

> maybe it's "clear" to other but it's pretty unclear.
> #mysql -username -p "select * from table_name where id=123" >
> '/home/me/test/test.txt'
> actually doesn't work?!?
>
>
>
>
> Jerry Schwartz wrote:
>
>> The technique I've settled on is this:
>>
>> mysql blah blah blah < the_select_query.sql > the_output_i_want.txt
>>
>> That gives you a tab-delimited text file with column headings.
>>
>> Regards,
>>
>> Jerry Schwartz
>> Global Information Incorporated
>> 195 Farmington Ave.
>> Farmington, CT 06032
>>
>> 860.674.8796 / FAX: 860.674.8341
>> E-mail: jerry [at] gii.co.jp
>> Web site: www.the-infoshop.com
>>
>>
>>
>>> -----Original Message-----
>>> From: LAMP [mailto:lamp [at] afan.net]
>>> Sent: Saturday, January 08, 2011 6:05 PM
>>> To: mysql [at] lists.mysql.com
>>> Subject: export result from select statement
>>>
>>> Hi guys,
>>> I wonder how to store to csv or txt file result from SELECT query?
>>> not a whole table nor database. Just results from SELECT query.
>>> Usually I use MySQL Query Browser and Export feature, but in this
>>> case I don't have access with MySQL Query Browser. Though, I have a
>>> command line access.
>>> I found on one place something like
>>> #SELECT 2+2 into outfile '/path/to/specific/directory/test.csv';
>>> Though, it doesn't work?!?
>>>
>>> Thanks.
>>>
>>> --
>>> MySQL General Mailing List
>>> For list archives: http://lists.mysql.com/mysql
>>> To unsubscribe: http://lists.mysql.com/mysql?unsub=jerry [at] gii.co.jp
>>>
>>>
>>
>>
>>
>>
>>
>>
>>
>
>

--001517479648202863049977a84c--
Yogesh Kore [ Mo, 10 Januar 2011 06:58 ] [ ID #2052807 ]

RE: export result from select statement

>-----Original Message-----
>From: LAMP [mailto:lamp [at] afan.net]
>Sent: Sunday, January 09, 2011 9:46 PM
>To: mysql [at] lists.mysql.com
>Subject: Re: export result from select statement
>
>maybe it's "clear" to other but it's pretty unclear.
>#mysql -username -p "select * from table_name where id=123" >
>'/home/me/test/test.txt'
>actually doesn't work?!?
>
>
[JS] The command you wrote doesn't redirect the input of the client. It should
read

#mysql -username -pxxx dbname < /home/me/testing/text.sql >
/home/me/testing/text.txt

By the way, it is a bad idea to use "test" as a file or directory name. It is
very easy to accidentally invoke the "test" command, which can really make you
scratch your head.

Regards,

Jerry Schwartz
Global Information Incorporated
195 Farmington Ave.
Farmington, CT 06032

860.674.8796 / FAX: 860.674.8341
E-mail: jerry [at] gii.co.jp
Web site: www.the-infoshop.com



>
>Jerry Schwartz wrote:
>> The technique I've settled on is this:
>>
>> mysql blah blah blah < the_select_query.sql > the_output_i_want.txt
>>
>> That gives you a tab-delimited text file with column headings.
>>
>> Regards,
>>
>> Jerry Schwartz
>> Global Information Incorporated
>> 195 Farmington Ave.
>> Farmington, CT 06032
>>
>> 860.674.8796 / FAX: 860.674.8341
>> E-mail: jerry [at] gii.co.jp
>> Web site: www.the-infoshop.com
>>
>>
>>> -----Original Message-----
>>> From: LAMP [mailto:lamp [at] afan.net]
>>> Sent: Saturday, January 08, 2011 6:05 PM
>>> To: mysql [at] lists.mysql.com
>>> Subject: export result from select statement
>>>
>>> Hi guys,
>>> I wonder how to store to csv or txt file result from SELECT query?
>>> not a whole table nor database. Just results from SELECT query.
>>> Usually I use MySQL Query Browser and Export feature, but in this
>>> case I don't have access with MySQL Query Browser. Though, I have a
>>> command line access.
>>> I found on one place something like
>>> #SELECT 2+2 into outfile '/path/to/specific/directory/test.csv';
>>> Though, it doesn't work?!?
>>>
>>> Thanks.
>>>
>>> --
>>> MySQL General Mailing List
>>> For list archives: http://lists.mysql.com/mysql
>>> To unsubscribe: http://lists.mysql.com/mysql?unsub=jerry [at] gii.co.jp
>>>
>>
>>
>>
>>
>>
>>





--
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe: http://lists.mysql.com/mysql?unsub=gcdmg-mysql-2 [at] m.gmane.org
Jerry Schwartz [ Mo, 10 Januar 2011 16:22 ] [ ID #2052809 ]

RE: export result from select statement

>-----Original Message-----
>From: Michael Dykman [mailto:mdykman [at] gmail.com]
>Sent: Sunday, January 09, 2011 3:02 PM
>To: LAMP; mysql [at] lists.mysql.com
>Subject: Re: export result from select statement
>
>I second Jerry's recommendation. It always works like a charm for me.
>
[JS] Thanks.

By the way, if your SELECT is easy to type you can use the -e parameter on the
MySQL command line.

Regards,

Jerry Schwartz
Global Information Incorporated
195 Farmington Ave.
Farmington, CT 06032

860.674.8796 / FAX: 860.674.8341
E-mail: jerry [at] gii.co.jp
Web site: www.the-infoshop.com



> - michael dykman
>
>On Sun, Jan 9, 2011 at 2:44 PM, Jerry Schwartz <jerry [at] gii.co.jp> wrote:
>> The technique I've settled on is this:
>>
>> mysql blah blah blah < the_select_query.sql > the_output_i_want.txt
>>
>> That gives you a tab-delimited text file with column headings.
>>
>> Regards,
>>
>> Jerry Schwartz
>> Global Information Incorporated
>> 195 Farmington Ave.
>> Farmington, CT 06032
>>
>> 860.674.8796 / FAX: 860.674.8341
>> E-mail: jerry [at] gii.co.jp
>> Web site: www.the-infoshop.com
>>
>>>-----Original Message-----
>>>From: LAMP [mailto:lamp [at] afan.net]
>>>Sent: Saturday, January 08, 2011 6:05 PM
>>>To: mysql [at] lists.mysql.com
>>>Subject: export result from select statement
>>>
>>>Hi guys,
>>>I wonder how to store to csv or txt file result from SELECT query?
>>>not a whole table nor database. Just results from SELECT query.
>>>Usually I use MySQL Query Browser and Export feature, but in this
>>>case I don't have access with MySQL Query Browser. Though, I have a
>>>command line access.
>>>I found on one place something like
>>>#SELECT 2+2 into outfile '/path/to/specific/directory/test.csv';
>>>Though, it doesn't work?!?
>>>
>>>Thanks.
>>>
>>>--
>>>MySQL General Mailing List
>>>For list archives: http://lists.mysql.com/mysql
>>>To unsubscribe: http://lists.mysql.com/mysql?unsub=jerry [at] gii.co.jp
>>
>>
>>
>>
>>
>> --
>> MySQL General Mailing List
>> For list archives: http://lists.mysql.com/mysql
>> To unsubscribe: http://lists.mysql.com/mysql?unsub=mdykman [at] gmail.com
>>
>>
>
>
>
>--
> - michael dykman
> - mdykman [at] gmail.com
>
> May the Source be with you.
>
>--
>MySQL General Mailing List
>For list archives: http://lists.mysql.com/mysql
>To unsubscribe: http://lists.mysql.com/mysql?unsub=jerry [at] gii.co.jp





--
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe: http://lists.mysql.com/mysql?unsub=gcdmg-mysql-2 [at] m.gmane.org
Jerry Schwartz [ Mo, 10 Januar 2011 16:22 ] [ ID #2052810 ]
Datenbanken » gmane.comp.db.mysql.general » export result from select statement

Vorheriges Thema: Reading .MYD file of Mysql Tables
Nächstes Thema: Help needed with what appears to be a corrupted innodb db