title: Doing database JOIN in django
body: <p>I want to do equivalent query as <code>SELECT user_name, item_name FROM users, items WHERE users.favor_item_id = items.item_id</code>, which is to return user_name and item_name pairs. In the database, one user can have multiple favoured items.</p>
  
  <p>I'm just curious what is a equivalent Django query for this SQL query??</p>
  
  <p>My first thought is to list all (user, favor_item_id) pair from USERS, and then look for item_name with id item_id. But it seems that it will search the ITEM table N times(N is the number of pairs), which has complexity of O(NlogM)(M is number of items in ITEM), while using the SQL query above, the complexity is O(N).</p>
  
  <p>Is there a more efficient way of doing this in django(or any ORM system)?</p>