I have three tables, a user-table and two user-type tables. The user-type tables have a field UserId so they can be linked. The question/problem now is that I have an entry from the user-table. What is the best way to get the data from the right table?
Is it correct to use 2 right joins or can this be done more elegantly?
Yes, but I’d use LEFT OUTER JOIN. That is, you want the row from UserTable, and then possibly a row from the appropriate UserType table, if such a row exists.
Here’s an example:
Presumably at most one of the user-type tables has an entry. So either t1.* or t2.* will be a single row of all NULLs, and you won’t get multiple rows due to Cartesian product.