1

I would like to do a SQL request in VBA that avoids some values.

  1. 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)

  2. 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

1
  • What does the SQL for the first request look like? Commented Nov 27, 2018 at 22:38

1 Answer 1

2

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
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.