title: python - sqlite3 returning wrong results
body: <p>If I run this query directly in sqlite3.exe on the same database, I get 20 records.</p>
  
  <p>When I run it in Python using sqlite3, it returns every single record from table a (200000+).</p>
  
  <pre><code>import sqlite3
  db = sqlite3.connect("path/to/my.db")
  c = db.cursor()
  c.execute("""SELECT a.*, b.*, c.* FROM t_data a NATURAL LEFT JOIN t_finished b
              NATURAL LEFT JOIN user_info c WHERE user_id=1;""")
  for row in c:
      print row
  </code></pre>
  
  <p>How can this be possible?</p>
  
  <hr>
  
  <p>Here is how the tables are related.</p>
  
  <pre><code>CREATE TABLE t_data ( t_id INTEGER  REFERENCES t_finished (t_id),
      ui_id INTEGER  NOT NULL  REFERENCES user_info (ui_id), ...);
  
  CREATE TABLE t_finished ( t_id INTEGER  PRIMARY KEY, ...);
  
  CREATE TABLE user_info ( ui_id INTEGER  PRIMARY KEY, user_id INTEGER  REFERENCES accounts, ...);
  </code></pre>
  
  <p>No other columns are shared between them.</p>
  
  <hr>
  
  <p>Trying to use explicit JOINS I have the same problem:</p>
  
  <pre><code>SELECT * FROM t_data a LEFT JOIN t_finished b USING(t_id) LEFT JOIN user_info c USING(ui_id) WHERE user_id=1;
  </code></pre>
  
  <p>This query works in sqlite3.exe, but throws an error in Python:</p>
  
  <pre><code>OperationalError: cannot join using column ui_id - column not present in both tables
  </code></pre>