title: PostgreSQL, Inner Join SELECT using three tables
body: <p>I have three tables in my database; walls, keys and wallAccessKeys.</p>
  
  <pre><code>CREATE TABLE walls (
    id SERIAL PRIMARY KEY,
    name VARCHAR(50)
  );
  
  INSERT INTO walls (name)
  VALUES ('Test Wall');
  
  CREATE TABLE keys (
      id SERIAL PRIMARY KEY,
      key VARCHAR(50)
  );
  
  INSERT INTO keys (key)
  VALUES ('testingtesting123');
  
  CREATE TABLE wallAccessKeys (
    id SERIAL PRIMARY KEY,
    keyID INT,
    wallID INT
  );
  
  INSERT INTO wallAccessKeys (keyID, wallID)
  VALUES (1, 1);
  </code></pre>
  
  <p>Walls should only be accessible with certain keys, the keys that access each wall is stored in the <code>wallAccessKeys</code> table.</p>
  
  <p>Walls have many keys, keys open many walls.</p>
  
  <p>I'm trying to write an SQL statement to select <code>wall.ID</code> given <code>keys.key</code> value.</p>
  
  <p>I've gotten so far using an Inner Join on <code>wall</code> and <code>wallAccessKeys</code> but can't figure this out.</p>
  
  <pre><code>SELECT *
  FROM walls
  INNER JOIN wallAccessKeys
  ON walls.ID = wallAccessKeys.wallID
  </code></pre>
  
  <p>Is using Inner join the best way to do this? If so please, could someone help me with the SQL?</p>
  
  <p>To summarize, I need an SQL statement where I can provide a key value e.g. testingtesting123, and get a list of walls that key has access to.</p>