title: missing FROM-clause entry for table in SQLAlchemy
body: <p>This is my query builder method:</p>
  
  <pre><code>def query_builder(search_parameter):
      query = BusinessOwner.query
      # query = query.select_from(BusinessOwnerTask)
      query = query.join(services, BusinessOwnerTask.services_id == services.c.id). \
          join(BusinessOwnerTask, BusinessOwnerTask.business_owner_id == BusinessOwner.id)
      query = query.filter(services.c.service_grade_id == search_parameter.service_grade)
      if len(search_parameter.name) &gt; 0:
          query = query.filter(BusinessOwner.name == search_parameter.name)
      if len(search_parameter.service_types) &gt; 0:
          query = query.filter(BusinessOwnerTask.services_id.in_(search_parameter.service_types))
  
      return query
  </code></pre>
  
  <p>This code has been run on <strong>sqlite3</strong> ,However, when <strong>query.all()</strong> calls, it complains on <strong>postgres</strong>:</p>
  
  <blockquote>
    <p>ProgrammingError: (psycopg2.ProgrammingError) missing FROM-clause
    entry for table "business_owner_tasks" LINE 2: FROM business_owners
    JOIN services ON business_owner_tasks.s...</p>
  </blockquote>
  
  <p>I decided to add this:</p>
  
  <pre><code>query = query.select_from(BusinessOwnerTask)
  </code></pre>
  
  <p>It complains:</p>
  
  <blockquote>
    <p>ProgrammingError: (psycopg2.ProgrammingError) table name
    "business_owner_tasks" specified more than once</p>
  </blockquote>
  
  <p>What is my mistake?</p>