Alexander Alexander - 1 year ago 331
SQL Question

how to make join after where condition with peewee

Is that possible making join after where condition like that

query = (AppCompany

if request.args.industry:
query = query.switch(AppCompany).join(AppCompanyToIndustry)
query = query.where(AppCompanyToIndustry.industry_id==request.args.industry)

I tired but it throwed this error : "ValueError: A join condition must be specified."

Answer Source

Provide a join condition

query = query.switch(AppCompany)
             .where(AppCompanyID == AppCompanyToIndustryID)

Here you should replace AppCompanyID and AppCompanyToIndustryID with proper column

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download