Reputation: 67
I would like to do a SQL request in VBA that avoids some values.
First I do a request that give me the values I do not want:
I put those values in a table a
for example: a = (1, 25, 3)
Then I would like to do a request like:
rst.Source = "SELECT TableNumerosClients.NOM_CLIENT ," & _
"FROM table.Clients WHERE NOT table.id in a ;"
My problem here is a, I do not know how to make the query understand that a = (1, 25, 3)
Thanks
Upvotes: 1
Views: 65
Reputation: 16015
Assuming that your example object a
is genuinely a table and not an array of values, there are a couple of ways to accomplish this:
Using a subquery in the WHERE
clause:
select c.nom_client
from clients c
where c.id not in (select a.id from a)
Using a LEFT JOIN
:
select c.nom_client
from clients c left join a on c.id = a.id
where a.id is null
Upvotes: 2