Skip to content
Advertisement

SQL Update when not in subquery?

I have 2 tables:

tblAbsence

tblManning

I would like to be able to update tblAbsence.Status to “Approved” as long as the Required value during the absence request doesn’t exceed an arbitrary limit (4 for example).

After looking at @Jeffrey’s proposal and experimenting I think I need an Update query which Sets [Status]= Approved when leave request is not found in query below. The below query will tell me if a request has any days that exceed the Limit.

I renamed the above query as qryLv and tried this Left Join but it tells me I must use an updatable query????

Advertisement

Answer

Your error is showing because you have to either equate or use IN/EXISTS with a variable when using subqueries in WHERE clauses. However, I’m not sure you need a subquery, I think something like this will work:

Ok, kinda missed that part, you will need a subquery. I think you need to use NOT EXISTS just to check if your subquery returns any values or not and that should work for you.

I think you can use NULL in the subquery since you are not returning records, just a boolean, but if it doesn’t work you can replace it with *.

User contributions licensed under: CC BY-SA
5 People found this is helpful
Advertisement