gpt4 book ai didi

mysql-workbench - 如何将 DISTINCT 数据导出到 DISTINCT 文件

转载 作者:行者123 更新时间:2023-11-29 22:14:23 27 4
gpt4 key购买 nike

SELECT * 
FROM `amc_info`
WHERE department =' (
SELECT DISTINCT department )
into outfile = 'Different department'

我在 amc_info 中有大量数据,涉及不同的部门。一个部门可能有多于一行,总部门超过30个,现在我想用部门文件名导出此数据。

最佳答案

我认为这就是您想要实现的目标:

SELECT * INTO OUTFILE 'file.txt' 
FROM `amc_info` WHERE department IN (SELECT DISTINCT department FROM `amc_info`)

也查看 SELECT INTO 语法:https://dev.mysql.com/doc/refman/5.1/en/select-into.html

如果您只是想获取不同的部门:

SELECT DISTINCT department INTO OUTFILE 'file_name.txt'
FROM `amc_info`

关于mysql-workbench - 如何将 DISTINCT 数据导出到 DISTINCT 文件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31337279/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com