mysql 怎么导入/导出2个关联表中的数据
表一
id student
1 S1
2 S2
表二
id sid scord order
1 1 100 1
2 1 60 2
3 1 80 3
4 2 60 1
5 2 60 2
6 2 80 3
7 2 100 4
导出后的格式为:---怎么实现????
id student scord order
1 S1 100 1
2 S1 60 2
3 S1 80 3
4 S2 60 1
5 S2 60 2
6 S2 80 3
7 S2 100 4
------解决方案--------------------
select a.*,b.scord,b.order INTO OUTFILE '/tmp/result.CSV'
FIELDS TERMINATED BY ',' OPTIONALLY ENCLOSED BY '"'
LINES TERMINATED BY '\n'
from 表一 a inner join 表二 b on a.id=b.sid
------解决方案--------------------SELECT a.*,b.scord,b.order
FROM 表一 a INNER JOIN 表二 b ON a.id=b.sid
INTO OUTFILE 'xxx.txt'
FIELDS TERMINATED BY '\t'
------解决方案--------------------select b.id,a.student, b.scord,b.orderer
into OUTFILE 'C:\\result.CSV'
FIELDS TERMINATED BY ','
OPTIONALLY ENCLOSED BY '"'
LINES TERMINATED BY '\n'
from 第一张表 a inner join 第二张表 b on a.id = b.sid
输出结果保存到c盘