JW_513
JW_513

Reputation: 11

Need assistance with SQL in Excel, specifically the "?" Parameter

I've set up this SQL query in excel:

SELECT * FROM acct.view_op_seremain

WHERE SEC_ID = (?)

I've directed the "?" parameter to cell A1 in Excel. Now, I want this A1 parameter cell to contain multiple values but I am unsure if it requires special formatting? So far I have tried to do the following in Cell A1:

Justin, John, James

('Justin','John','James')

'Justin','John','James'

None of those formats are giving me results. Do you know what I am doing wrong?

Upvotes: 1

Views: 65

Answers (2)

Mathieu Guindon
Mathieu Guindon

Reputation: 71207

You're close. It's just that = compares only a single value, and you're trying to give it multiple ones. Try an IN statement:

WHERE SEC_ID IN (?)

And then this input string should work:

'Justin','John','James'

Upvotes: 1

to StackOverflow
to StackOverflow

Reputation: 124746

You can't pass multiple parameters in that way.

Depending on what database you're using, you may be able to pass a single string parameter to the databaase engine, and have the database engine split the string for you.

For example, this answer has a solution for SQL Server.

Upvotes: 0

Related Questions