Forum Discussion
altoma75
Dec 13, 2022Copper Contributor
Customize a parameter query with a string
I have a SQL query written and saved in Excel.
In the where clause I can use:
where dept = ?
and then set the parameter to reference a cell where the user inputs their dept.
However, I need to be able to enter a string of departments and change my where to an 'in' instead of '='.
I need it to be: where dept in (xxxx,xxxx,xxxx).
How can I write this and use the ? parameter to reference a list of depts and have the string of departments saved in a cell?
1 Reply
Sort By
- peiyezhuBronze Contributorconcatenate sql string before run it?
like
s="select * from aa where f1 in (" & cells(1,1) & ")"
rs.open cnn,s