嗨,下面是我的 mysql 查询
select CONCAT(si.ID_PREFIX, si.ID_COUNT) as ID, tmp.NEW_VALUE from ( select ACTIVITY_ID, ISSUE_ID, OLD_VALUE, NEW_VALUE from SCARAB_ACTIVITY where ISSUE_ID in (select ISSUE_ID from SCARAB_ISSUE where MODULE_ID = 656) and (NEW_VALUE like 'http%') order by ACTIVITY_ID desc) tmp, SCARAB_ISSUE si where tmp.ISSUE_ID = si.ISSUE_ID INTO OUTFILE '/tmp/nxh5102_relatedlinks.csv' FIELDS ENCLOSED BY '' TERMINATED BY ',';
上面的代码会收集数据并将其存储到 csv 文件中,如下所示:
SEE25,https://www.hello.com/sf/tracker/do/viewArtifact/projects.ip_forge/tracker.open_issues/artf31417?_message=1344426489584&returnUrlKey=
SEE355,https://www.google.com/svn/nxh5102/trunk/doc/010 Architecture and Design/MRA3/PRCR doc/NxHSEE355.pptx
我需要在第一行中添加一行,如下所示:
Artifact ID,Related Links
SEE25,https://www.hello.com/sf/tracker/do/viewArtifact/projects.ip_forge/tracker.open_issues/artf31417?_message=1344426489584&returnUrlKey=
SEE355,https://www.google.com/svn/nxh5102/trunk/doc/010 Architecture and Design/MRA3/PRCR doc/NxHSEE355.pptx
我想要这个,这样当我在 Excel 中打开 csv 时,我可以在前两列中看到它们。任何建议都会有帮助。
最佳答案
SELECT 'artifact' id
, 'related links' new_value
UNION
SELECT CONCAT(si.id_prefix, si.id_count)
, si.new_value
FROM scarab_activity sa
JOIN scarab_issue si
ON si.issue_id = sa.issue_id
WHERE si.module_id = 656
AND sa.new_value LIKE 'http%'
关于mysql - 需要使用mysql查询在前两列中注入(inject)数据,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42267446/