1

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?

rink.attendant.6
  • 40,889
  • 58
  • 100
  • 149
JW_513
  • 11
  • 1

2 Answers2

2

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'
Mathieu Guindon
  • 67,201
  • 8
  • 101
  • 218
0

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.

Community
  • 1
  • 1
Joe
  • 118,426
  • 28
  • 194
  • 329