title: Inner join of child table with parent table
body: <p>I have two tables, related by a foreign key. I want to select a column from the child table based on some information about a row in the parent table. </p>
  
  <p>The definitions of the tables are:</p>
  
  <pre><code>CREATE TABLE Runs(
      id            INTEGER, 
      name          TEXT UNIQUE NOT NULL, 
      rundate       TEXT NOT NULL,
      PRIMARY KEY (id)
  );
  
  
  CREATE TABLE Location(
      lid           INTEGER, 
      rid           INTEGER NOT NULL,
      direc         TEXT NOT NULL,
      PRIMARY KEY (lid), 
      FOREIGN KEY (rid) REFERENCES Runs(id)
  );
  </code></pre>
  
  <p>I am new to SQL so I have not quite figured out how to do this. This is what I have so far (suppose I want to get the directory for run named 012114:</p>
  
  <pre><code>SELECT direc FROM Location INNER JOIN Runs WHERE Runs.name = '012114';
  </code></pre>
  
  <p>I've also tried</p>
  
  <pre><code>SELECT direc FROM Location INNER JOIN (SELECT * FROM Runs WHERE Name = '012114');
  </code></pre>
  
  <p>Both of these attempts lists all entries from the direc column in the Location table. I am using sqlite. </p>