select ... into local outfile ... ???

select ... into local outfile ... ???

am 02.09.2011 21:40:56 von Dennis

--0-1188544925-1314992456=:73286
Content-Type: text/plain; charset=iso-8859-1
Content-Transfer-Encoding: quoted-printable

hi, there,
the following is my sql statement:
SELECT   HIGH_PRIORITY   SQL_BIG_RESULT   SQL_NO_CACHE
=A0 tb.url_sign,=A0 m_url,    m_title,   m_weight  =A0 INTO OUT=
FILE   '/tmp/a.csv'=A0 FIELDS TERMINATED BY ',' =A0ENCLOSED BY '\"'=A0=
=A0 LINES =A0TERMINATED BY '\n' STARTING BY '=3D'
FROM d_local.ta, d_news.tbWHERE ta.url_sign =3D tb.url_sign

Before, the server and the client were on the same machine; now, I need to =
generate the output file on client (which is on a different machine from th=
e server). But it seams that there is no "select ... into LOCAL file" state=
ment.Any suggestion is=A0appreciated.
Dennis

--0-1188544925-1314992456=:73286--

Re: select ... into local outfile ... ???

am 02.09.2011 21:45:17 von Tyler Poland

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

Dennis,

The following closely simulates the default "INTO OUTFILE", you'll have
to modify it slightly for your purposes:
mysql --delimiter=comma -N < select_statement.sql \
| sed 's/\"/\\\"/g' \
| sed 's/\t/\",\"/g' \
| sed 's/$/\"/g' \
| sed 's/^/\"/g' \
| sed 's/\"NULL\"/\\N/g' \
| sed 's/\\t/\t/g' ' > output.txt


Tyler
*

*On 9/2/11 3:40 PM, Dennis wrote:
> hi, there,
> the following is my sql statement:
> SELECT HIGH_PRIORITY SQL_BIG_RESULT SQL_NO_CACHE
> tb.url_sign, m_url, m_title, m_weight INTO OUTFILE '/tmp/a.csv' FIELDS TERMINATED BY ',' ENCLOSED BY '\"' LINES TERMINATED BY '\n' STARTING BY '='
> FROM d_local.ta, d_news.tbWHERE ta.url_sign = tb.url_sign
>
> Before, the server and the client were on the same machine; now, I need to generate the output file on client (which is on a different machine from the server). But it seams that there is no "select ... into LOCAL file" statement.Any suggestion is appreciated.
> Dennis
>

--------------050805080204070707010309--

Re: select ... into local outfile ... ???

am 03.09.2011 05:30:55 von (Halász Sándor) hsv

>>>> 2011/09/03 03:40 +0800, Dennis >>>>
But it seems that there is no "select ... into LOCAL file" statement. Any suggestion is appreciated.
<<<<<<<<
Indeed: you can use only standard output.


--
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: select ... into local outfile ... ???

am 03.09.2011 10:31:58 von Dennis

--0-239768389-1315038718=:60111
Content-Type: text/plain; charset=iso-8859-1
Content-Transfer-Encoding: quoted-printable

Thanks,=A0Tyler,=A0
That's very helpful.
Dennis

--- On Sat, 9/3/11, Tyler Poland wrote:

From: Tyler Poland
Subject: Re: select ... into local outfile ... ???
To: mysql@lists.mysql.com
Date: Saturday, September 3, 2011, 3:45 AM

Dennis,

The following closely simulates the default "INTO OUTFILE", you'll have to =
modify it slightly for your purposes:
mysql --delimiter=3Dcomma -N < select_statement.sql \
=A0 | sed 's/\"/\\\"/g' \
=A0 | sed 's/\t/\",\"/g' \
=A0 | sed 's/$/\"/g' \
=A0 | sed 's/^/\"/g' \
=A0 | sed 's/\"NULL\"/\\N/g' \
=A0 | sed 's/\\t/\t/g' ' > output.txt


Tyler
*

*On 9/2/11 3:40 PM, Dennis wrote:
> hi, there,
> the following is my sql statement:
> SELECT  =A0HIGH_PRIORITY  =A0SQL_BIG_RESULT  =A0 SQL_NO_CACHE
>=A0 =A0 tb.url_sign,=A0 m_url,=A0 =A0 m_title,  =A0m_weight=A0 =A0 INT=
O OUTFILE  =A0'/tmp/a.csv'=A0 FIELDS TERMINATED BY ','=A0 ENCLOSED BY '=
\"'  =A0LINES=A0 TERMINATED BY '\n' STARTING BY '=3D'
> FROM d_local.ta, d_news.tbWHERE ta.url_sign =3D tb.url_sign
>=20
> Before, the server and the client were on the same machine; now, I need t=
o generate the output file on client (which is on a different machine from =
the server). But it seams that there is no "select ... into LOCAL file" sta=
tement.Any suggestion is appreciated.
> Dennis
>=20

--0-239768389-1315038718=:60111--