-2

In sql, if we have the following relations :

  • A(B,C) with values { (1,2), (3,4), (5,6) }

  • D(B,E) with values { (1,2), (3,4), (7,8), (9,10) }

Would the resulting table be BCE with values { (1,2,2), (3,4,4), (5,6,null), (7,null,8), (9,null,10) } for the operation:

SELECT * FROM A NATURAL FULL OUTER JOIN D

Also what would happen in the case of natural left outer join and natural right outer join?

GMB
  • 216,147
  • 25
  • 84
  • 135
  • 4
    Why don't you run those queries and find out for yourself? – Tim Biegeleisen Dec 09 '18 at 23:57
  • I tried, got error select * FROM (R NATURAL OUTER JOIN S) SQL0104N An unexpected token "NATURAL" was found following "select * FROM (R ". Expected tokens may include: "". SQLSTATE=42601 db2 => R NATURAL FULL OUTER JOIN S – Ahmed Akbarali Dec 10 '18 at 00:02
  • 1
    You get an error because your query is wrong. It should NOT be `select * FROM (R NATURAL OUTER JOIN S) SQL0104N'`, instead use `select * FROM R NATURAL OUTER JOIN S`, without '(' and ')' – J.D. Dec 10 '18 at 00:26
  • 1
    Please read & act on [mcve]. That includes DBMS (including version), a clear specification, cut & paste & runnable code (including input) & diffable expected output. Please clarify via post edits, not comments. Please always google error messages & many clear, concise & specific versions/phrasings of your question/problem/goal with & without your particular strings/names & 'site:stackoverflow.com' & tags & read many answers. Please always check the manual when you have problems with relatively new syntax. – philipxy Dec 10 '18 at 07:16
  • Forget about the NATURAL JOIN construction! Specify the JOIN conditions! – jarlh Dec 10 '18 at 07:20

1 Answers1

0

You can test these things easily using one of the many online database query interfaces, like SQL Fiddle: http://sqlfiddle.com/#!17/bc42d/1

Henning Koehler
  • 2,456
  • 1
  • 16
  • 20