Query performance

H

Hermione

HI

I have one table linked to 5 another tables with fis ID

I want to search all the ID not existing in the child table

I know that I can do:

Where (ID not in (SELECT ID FROM TB_1)
and ID not in (SELECT ID FROM TB_2)
and ID not in (SELECT ID FROM TB_3)
and ID not in (SELECT ID FROM TB_4)
and ID not in (SELECT ID FROM TB_5)

but is it performance this type of query or no?

another thing can I develop a funtion that takes the name of the field and
the name of the table and it`ll made the Query


Example:
intTables is the number of tables in an array

For i = 0 To intTables
strWhere = "Where (" & STRid & " not in (SELECT" & STRID & " FROM " &

intTables(i) & ")"
if intTables <> i then
strWhere = "and " & STRid & " not in (SELECT ID FROM " &
intTables(0) & ")"
end if
Next i


The idea is I want to automatise the query in case where I want to add a new
table as a child of the parent table so my function will automated

Thanks
 
Top