kayak / pypika

PyPika is a python SQL query builder that exposes the full richness of the SQL language using a syntax that reflects the resulting query. PyPika excels at all sorts of SQL queries but is especially useful for data analysis.
http://pypika.readthedocs.io/en/latest/
Apache License 2.0
2.43k stars 292 forks source link

Join on multiple columns not working #775

Closed raayu83 closed 5 months ago

raayu83 commented 7 months ago

I have a join on a subquery like this:

q_subquery = get_subquery().as_("q_subquery")
q = q.join(q_subquery).on(t_agg.x_id == q_subquery.x_id and t_agg.y_id == q_subquery.y_id)

For some reason, in the SQL generated only the second join condition is contained.

Am I doing the join the wrong way or is this a bug?

raayu83 commented 7 months ago

Seems you need to use & instead of and, will try this next week.

wd60622 commented 7 months ago

Seems you need to use & instead of and, will try this next week.

Yeah, try it with & instead of "and"

If that doesn't work, post your error message

wd60622 commented 5 months ago

Did using & resolve your issue? you will likely have to make sure that () are around the terms that you are comparing

raayu83 commented 5 months ago

Yes, it worked, thanks!