0

How to make MS Query work with comma separated parameters in Excel cell?

My query is:

SELECT *
FROM ABC
WHERE Id in (?)

When I put id number for example "1" the query works, but I want to put into a parameters cell a few id's 1, 2, 3, 4 etc, but then I'm trying to to this the query doesn't work... How can I put parameter with comma separated values?

jarlh
  • 42,561
  • 8
  • 45
  • 63
  • [This](https://social.msdn.microsoft.com/Forums/office/en-US/ac1aff14-9f59-4cd5-a993-9c0519dca774/query-parameter-with-comma-separated-numeric-values?forum=accessdev) may help – Ricardo Diaz Jan 24 '20 at 13:09

2 Answers2

0

You can use IN in you sql query.

SELECT column_name(s)
FROM table_name
WHERE column_name IN (1,2,3,4);

also try to use BETWEEN with comma as parameters.

SELECT column_name(s)
FROM table_name
WHERE column_name BETWEEN value1 AND value2;
Test
  • 1
  • 2
0

there is 2 diff way to do it:

select * from abc where id in ('1','2','3') etc but not in excel - maybe use notepad++

second way :)

select * from abc where (id like '1' or id like '2' or id like '3') etc 

:)

Artur Stolc
  • 41
  • 2
  • 9