【问题标题】:How to run SQL for column values against a 10k+ row excel doc如何针对超过 10k 行的 excel 文档对列值运行 SQL
【发布时间】:2014-09-26 20:08:21
【问题描述】:

所以我有一个 Excel 文档,其中一列中有 10k+ 个数字。我需要针对 SQL 表运行这些数字以从表中获取结果。

例如:

A 列中的 Excel 数据:

  • 10001
  • 10002
  • 10003
  • 10004
  • 等 10k+ 行

这是完成这项工作的查询:

 select 
 revenue,
 profit,
 brand,
 type
 from DB..orderAudits (nolock)
 where number = 10001

我可以在 Excel 中运行什么脚本、查询等,以使 SQL 查询对文档上的每一行重复 10k+ 次?

【问题讨论】:

  • 您可以使用哪些脚本语言?

标签: mysql sql excel


【解决方案1】:

如果你只需要这样做一次,那么我建议你要么

1) 将 excel 文档导入为表格,然后运行简单的连接

select 
revenue,
profit,
brand,
type
from DB..orderAudits o (nolock) 
join import_tbl i
on o.number = i.number

2) 在 excel 中突出显示整列,转到格式 - 自定义 -> 将其设置为 ['@',] 减去括号。复制该列,然后在您的数据库中,运行正常查询

Select
revenue,
profit,
brand,
type
from DB..orderAudits (nolock) 
where number in ( --paste copy here, go to last row and delete the extra comma )

【讨论】:

    猜你喜欢
    • 2011-05-13
    • 1970-01-01
    • 1970-01-01
    • 2022-12-13
    • 1970-01-01
    • 2013-12-14
    • 2019-07-30
    • 2013-03-19
    • 1970-01-01
    相关资源
    最近更新 更多