-1

I'm using MySql

So I have 5 tables and I'm trying to build a view which joins all these together and shows the missing information the current structure is.

plat (1 = Many) PG (1 = Many) TS

PG (1 = Many) PGHist

TT (1 = Many) TS

OR

enter image description here I am using MySql but I am not sure how to write this as you cannot use full joins as far as i'm aware in MySql can anyone help?

I need it so show nulls to any part.

  • "joins all these together and shows the missing information" is not clear. Please explain what your output looks like given some input. Please give example desired output for some input. – philipxy May 21 '16 at 02:11

1 Answers1

1

Consider using UNION of both LEFT JOIN and RIGHT JOIN to emulate the FULL JOIN in MySQL as follows:

SELECT * FROM PLAT
LEFT JOIN PG ON PG.FORGEIN_KEY = PLAT.PRIMARY_KEY
LEFT JOIN PGHIST ON PGHIST.FORGEIN_KEY = PG.PRIMARY_KEY
LEFT JOIN PG ON PG.FORGEIN_KEY = PLAT.PRIMARY_KEY
LEFT JOIN TS ON TS.FORGEIN_KEY = PG.PRIMARY_KEY
LEFT JOIN TT ON TT.FORGEIN_KEY = TS.PRIMARY_KEY

UNION

SELECT * FROM PLAT
RIGHT JOIN PG ON PG.FORGEIN_KEY = PLAT.PRIMARY_KEY
RIGHT JOIN PGHIST ON PGHIST.FORGEIN_KEY = PG.PRIMARY_KEY
RIGHT JOIN PG ON PG.FORGEIN_KEY = PLAT.PRIMARY_KEY
RIGHT JOIN TS ON TS.FORGEIN_KEY = PG.PRIMARY_KEY
RIGHT JOIN TT ON TT.FORGEIN_KEY = TS.PRIMARY_KEY
Shadi Shaaban
  • 1,670
  • 1
  • 10
  • 17