Skip to content
Advertisement

How to use triple INNER JOIN with one empty table?

Given is the following table:

A project can be either owned by a user (user_id), OR by an organization (org_id) So either field is 0. So I do an INNER JOIN on projects, users, and organizations, but if the project is owned by a user (and currently no organization does exist at all), the result is empty.

Does NOT work

Can anyone help me out? If I leave out organization, the result is 1 row, as expected.

Works

Advertisement

Answer

Learn to use proper, explicit, standard, readable JOIN syntax.

You seem to want:

I assume there is no id of 0 in the projects or organizations tables so the filtering is not necessary.

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