As an option, you could try rewriting your query like this:
SELECT
b1.NAME,
b2.NAME,
.
.
.
FROM TAB1 a
INNER JOIN TAB2 b1 ON a.ID1 = b1.ID
INNER JOIN TAB2 b2 ON a.ID1 = b1.ID
...
That will hardly make any difference in term of efficiency, but it at least might make your query more readable (which is subjective, of course).
There might be another option to consider but there are two big IFs I am not sure about: if it is applicable at all in your situation and if it will be more efficient.
The first one depends on the presence of a key in TAB1
. If there's no dedicated key column, it would be enough if all the combinations of (ID1, IF2, ... IDN)
were guaranteed to be unique. And whether this approach can be more efficient than your multiple lookups depends on the number of the IDx
columns.
The idea is to join the two table just once on a condition similar to the one in @dasblinkenlight's answer, then group by the key column(s) and pull the names using conditional aggregation. Here's what I mean:
SELECT
MAX(CASE TAB2.ID WHEN TAB1.ID1 THEN TAB2.NAME END) AS NAME1,
MAX(CASE TAB2.ID WHEN TAB1.ID2 THEN TAB2.NAME END) AS NAME2,
.
.
.
FROM TAB1
INNER JOIN TAB2 ON TAB2.ID IN (TAB1.ID1, TAB1.ID2, ...)
GROUP BY TAB1.ID1, TAB1.ID2, ...