select * from( select 'myname' as myname from dual union all select name1 as myname from table1 ) t into outfile 'c:\test.csv'
手动处理一下 select * from( select 'myname' as myname union all select name1 as myname from tt ) a into outfile 'c:\test.csv'
老大些,你们也太IN了吧。'c:\test.csv' \t.. 'c:\\test.csv'
我也是这样用的,貌似在test.csv文件里没有带字段名。
不是吧 SELECT * INTO OUTFILE 'R:/TEMP/test.csv' FROM ( SELECT 'AID' AS F1 UNION SELECT AID FROM A) A结果 AID 2 3 4
可以的,而且是个好方法.. mysql> select * from c; +-----+------+---------+ | pid | item | wgt | +-----+------+---------+ | 1 | 1 | 15.0000 | | 1 | 2 | 20.0000 | | 1 | 3 | 20.0000 | | 1 | 4 | 20.0000 | +-----+------+---------+ 4 rows in set (0.00 sec)mysql> select * into outfile 'D:\ASDASD.TXT' from ( -> select 'pid' as pid,'item' as item,'wgt' as wgt -> union all -> select * from c) cc; Query OK, 5 rows affected (0.20 sec) 文件里是这样的:pid item wgt 1 1 15 1 2 20 1 3 20 1 4 20
刚有遇到这个问题,贴一下我的解决方法: 新建一个mysql.sh,内容如下:mysql -u root -p -e "use mechanist;select id,repository_id,revision,committer,committed_on,comments,commit_date,scmid ,user_id from changesets where comments like '%#%' and id between (select id from changesets where comments like '%0 .16.0%' limit 1) and ( select id from changesets where comments like '%notice board%' order by id desc limit 1) " root@ubuntu:~# ./mysql.sh > /tmp/log.log root@ubuntu:~# sed -i 's/\t/,/g' /tmp/log.log 结果就有了,这几条语句可以合并。
select 'myname' as myname from dual
union all
select name1 as myname from table1
) t
into outfile 'c:\test.csv'
select * from(
select 'myname' as myname
union all
select name1 as myname from tt
) a into outfile 'c:\test.csv'
'c:\\test.csv'
SELECT * INTO OUTFILE 'R:/TEMP/test.csv' FROM (
SELECT 'AID' AS F1
UNION
SELECT AID FROM A) A结果
AID
2
3
4
mysql> select * from c;
+-----+------+---------+
| pid | item | wgt |
+-----+------+---------+
| 1 | 1 | 15.0000 |
| 1 | 2 | 20.0000 |
| 1 | 3 | 20.0000 |
| 1 | 4 | 20.0000 |
+-----+------+---------+
4 rows in set (0.00 sec)mysql> select * into outfile 'D:\ASDASD.TXT' from (
-> select 'pid' as pid,'item' as item,'wgt' as wgt
-> union all
-> select * from c) cc;
Query OK, 5 rows affected (0.20 sec)
文件里是这样的:pid item wgt
1 1 15
1 2 20
1 3 20
1 4 20
新建一个mysql.sh,内容如下:mysql -u root -p -e "use mechanist;select id,repository_id,revision,committer,committed_on,comments,commit_date,scmid ,user_id from changesets where comments like '%#%' and id between (select id from changesets where comments like '%0
.16.0%' limit 1) and ( select id from changesets where comments like '%notice board%' order by id desc limit 1) "
root@ubuntu:~# ./mysql.sh > /tmp/log.log
root@ubuntu:~# sed -i 's/\t/,/g' /tmp/log.log 结果就有了,这几条语句可以合并。