export result from select statement

export result from select statement

am 09.01.2011 00:04:44 von LAMP

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@m.gmane.org

Re: export result from select statement

am 09.01.2011 00:35:38 von Eric Bergen

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 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@g=
mail.com
>
>



--=20
Eric Bergen
eric.bergen@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@m.gmane.o rg

RE: export result from select statement

am 09.01.2011 20:44:43 von Jerry Schwartz

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@gii.co.jp
Web site: www.the-infoshop.com

>-----Original Message-----
>From: LAMP [mailto:lamp@afan.net]
>Sent: Saturday, January 08, 2011 6:05 PM
>To: mysql@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@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@m.gmane.org

Re: export result from select statement

am 09.01.2011 21:01:49 von Michael Dykman

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 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@gii.co.jp
> Web site: www.the-infoshop.com
>
>>-----Original Message-----
>>From: LAMP [mailto:lamp@afan.net]
>>Sent: Saturday, January 08, 2011 6:05 PM
>>To: mysql@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@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@gmail=
..com
>
>



--=20
=A0- michael dykman
=A0- mdykman@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@m.gmane.o rg

Re: export result from select statement

am 10.01.2011 03:42:03 von LAMP

--------------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 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@gmail.com
>>
>>
>>
>
>
>
>


--------------090704070908030402090709--

Re: export result from select statement

am 10.01.2011 03:45:48 von LAMP

--------------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@gii.co.jp
> Web site: www.the-infoshop.com
>
>
>> -----Original Message-----
>> From: LAMP [mailto:lamp@afan.net]
>> Sent: Saturday, January 08, 2011 6:05 PM
>> To: mysql@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@gii.co.jp
>>
>
>
>
>
>
>


--------------060308010105020200080501--

Re: export result from select statement

am 10.01.2011 06:58:27 von Yogesh Kore

--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 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@gii.co.jp
>> Web site: www.the-infoshop.com
>>
>>
>>
>>> -----Original Message-----
>>> From: LAMP [mailto:lamp@afan.net]
>>> Sent: Saturday, January 08, 2011 6:05 PM
>>> To: mysql@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@gii.co.jp
>>>
>>>
>>
>>
>>
>>
>>
>>
>>
>
>

--001517479648202863049977a84c--

RE: export result from select statement

am 10.01.2011 16:22:39 von Jerry Schwartz

>-----Original Message-----
>From: LAMP [mailto:lamp@afan.net]
>Sent: Sunday, January 09, 2011 9:46 PM
>To: mysql@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@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@gii.co.jp
>> Web site: www.the-infoshop.com
>>
>>
>>> -----Original Message-----
>>> From: LAMP [mailto:lamp@afan.net]
>>> Sent: Saturday, January 08, 2011 6:05 PM
>>> To: mysql@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@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@m.gmane.org

RE: export result from select statement

am 10.01.2011 16:22:39 von Jerry Schwartz

>-----Original Message-----
>From: Michael Dykman [mailto:mdykman@gmail.com]
>Sent: Sunday, January 09, 2011 3:02 PM
>To: LAMP; mysql@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@gii.co.jp
Web site: www.the-infoshop.com



> - michael dykman
>
>On Sun, Jan 9, 2011 at 2:44 PM, 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@gii.co.jp
>> Web site: www.the-infoshop.com
>>
>>>-----Original Message-----
>>>From: LAMP [mailto:lamp@afan.net]
>>>Sent: Saturday, January 08, 2011 6:05 PM
>>>To: mysql@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@gii.co.jp
>>
>>
>>
>>
>>
>> --
>> MySQL General Mailing List
>> For list archives: http://lists.mysql.com/mysql
>> To unsubscribe: http://lists.mysql.com/mysql?unsub=mdykman@gmail.com
>>
>>
>
>
>
>--
> - michael dykman
> - mdykman@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@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@m.gmane.org