下面是 Excel 中的示例表格:
ID Name Account
1 Jon 001
2 Snow 002
3 Alive 003
我想根据帐户创建一条SQL。看起来像,
SELECT * FROM CUSTOMER_TABLE WHERE ACCOUNT=' ';
是否可以让系统满足ACCOUNT=' '
?就像系统可以自动输入每个值。
它应该像WHERE ACCOUNT='C1', ACCOUNT='C2', ACCOUNT='C3'...
最佳答案
我假设您将帐户复制到 Range("E1:E10")
之类的范围内。
然后,您可以使用 for 循环来更改每轮的帐户。
将您的查询更改为,
SQL_Query = "Select * From Customer_Table Where Account ="
然后尝试 For 循环
。
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
关于mysql - 如何将特定单元格提取到 EXCEL 中的 SQL,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37022286/