Skip to content
Advertisement

Oracle Sql join two tables

I have a query joining two tables.

The RESULT_TABLE will typically have only one result per student. A student will usually have two email addresses in the EMAIL_TABLE, one of type ‘Personal’, and one of type ‘Student’.
I need a query that joins the student’s result and the two email addresses into one row.

My Query uses two instances of EMAIL_TABLE to do this:

Sample result:

This query works in most cases, displaying the result and both types of email addresses for the student.

The problem is, if one of the email_types is missing from the email_table then the entire result is not found. I need it to display a result for each student even if one or both email addresses do not exist in the email_table.

What is the proper way to do this join?

Advertisement

Answer

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

You can use two left joins:

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