简体   繁体   English

如何在EXCEL中将特定单元格提取到我的SQL

[英]how to extract particular cell to my SQL in EXCEL

Here is a example table in Excel: 这是Excel中的示例表:

ID Name  Account
1  Jon   001
2  Snow  002
3  Alive 003

I want to create a SQL according to account. 我想根据帐户创建一个SQL。 It looks like, 看起来像,

SELECT * FROM CUSTOMER_TABLE WHERE ACCOUNT=' ';

Is it possible to make system could fulfill ACCOUNT=' ' ? 是否有可能使系统满足ACCOUNT=' ' Like system could input each value automatically. 像系统可以自动输入每个值。

It should like WHERE ACCOUNT='C1', ACCOUNT='C2', ACCOUNT='C3'... 它应该是WHERE ACCOUNT='C1', ACCOUNT='C2', ACCOUNT='C3'...

I assume you copied your accounts into a range like Range("E1:E10") . 我假设您将帐户复制到了Range("E1:E10")类的Range("E1:E10")内。 Then you can use a for loop to change accounts for every turn. 然后,您可以使用for循环更改每个回合的帐户。 Change your Query as, 将您的查询更改为

SQL_Query = "Select * From Customer_Table Where Account ="

then try a For Loop . 然后尝试一个For Loop

Dim Query as String
For i = 1 to 10
    Query = SQL_Query & Cells(i,4).value
    'Do your query here.
    'Be careful about that your results should be copied under the last row.
    'Otherwise only the last one will be shown.
Next

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何在VBA上的SQL查询中将单元格Excel单元格引用定义为参数? - how to define cell excel cell reference as a parameter in SQL query on VBA? 如何为我的sql中的特定ID检索最后插入的nrecord - how to retrieve last inserted nrecord for a particular ID in my sql 从mysql的任何特定行单元格中提取细节 - extract details from any particular row cell of mysql 当单元格/列包含某些文本时,如何从Excel数据集中提取所有行 - How to extract all rows from excel data set when cell/column contains certain text 如何编写 sql REGEXP_REPLACE 语句以仅替换单元格的特定部分? - How do I write a sql REGEXP_REPLACE statement to only replace a particular section of a cell? How can I use Excel to interact with MySQL and show result of an SQL query in a cell, after I enter SQL table id in another cell? - How can I use Excel to interact with MySQL and show result of an SQL query in a cell, after I enter SQL table id in another cell? 从sql提取数据并插入excel - extract data from sql and insert into excel 在Excel中按日期查询SQL引用(单元格) - SQL query by date with reference in excel (cell) mysql,如何优先考虑具有特定值的单元格 - mysql, how to give priority to a cell with a particular value 如何在EJS的表格中的特定单元格中排列数据 - how to arrange the data in particular cell in table in EJS
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM