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
  • 44,500
  • 61
  • 101
  • 156
JW_513
  • 11
  • 1

2 Answers2

1

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
  • 69,817
  • 8
  • 107
  • 235
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
  • 122,218
  • 32
  • 205
  • 338