MySQL Forums
Forum List  »  German

Find missing entries in a table that contains ids from 2 tables
Posted by: Ronny Drechsler-Hildebrandt
Date: January 30, 2018 10:32AM

Hi

I have 3 tables

Table1:
id
name

Values:
(1,'standard')
(2,'premium')
(3,'exclusive')

Table2:
id
name

Values:
(1,'spring')
(2,'summer')
(3,'fall')
(4,'winter')

Table3:
id
id_table1
id_table2
price

As you can see table 3 contains entries that are related to table 1 and table 2.
Lets add some entries in table 3

(1,1,1,'12.00')
(2,1,2,'13.00')
(3,1,3,'14.00')
(4,1,4,'15.00')

Now I want to check, what prices are missing in table 3 for all possible relations of table1 and table 2 so that the result should be something like that:

(1,1,1,'12.00')
(2,1,2,'13.00')
(3,1,3,'14.00')
(4,1,4,'15.00')
(NULL,2,1,NULL)
(NULL,2,2,NULL)
(NULL,2,3,NULL)
(NULL,2,4,NULL)
(NULL,3,1,NULL)
(NULL,3,2,NULL)
(NULL,3,3,NULL)
(NULL,3,4,NULL)

Is there a possible query that could display the result as shown above?

Thanks!

Options: ReplyQuote


Subject
Views
Written By
Posted
Find missing entries in a table that contains ids from 2 tables
840
January 30, 2018 10:32AM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.