1

I have a problem with a select. I try to get a join between 2 tables: Items and Characters. The thing is, I have a third table Items_history. I want my select to show ALL items and ALL characters and, if there's a record, that a character had or has an item, show it.

Shortly speaking, I want something like this:

ID | Character
 4 | 
 5 |
10 | Player1
12 | Player1
12 | Player2
13 | Player3
20 | Player2
   | Player4
   | Player5

My code right now:

SELECT Items.ID, Character.Name
FROM Items_history
RIGHT JOIN Items
ON Items.ID = Items_history.ID
RIGHT JOIN Characters
ON Characters.Name = Items_history.Name;
Chmielok
  • 150
  • 1
  • 7
  • 2
    You wrote "Full outer join" in the question title, but use `RIGHT JOIN` in your query. Simply changing the joins to `FULL JOIN` should return the expected result. – dnoeth Apr 25 '15 at 12:47
  • You might find this helpful as it shows how to nest the joins: http://stackoverflow.com/a/3721771/2515265 – Javide Apr 25 '15 at 12:51
  • As @dnoeth suggested, simple replacing right joins with full joins gives [expected results](http://sqlfiddle.com/#!4/0d198a/1). – Ponder Stibbons Apr 25 '15 at 13:28

0 Answers0