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

NOT BETWEEN possible? #772

Closed info-rchitect closed 5 months ago

info-rchitect commented 7 months ago

Hi,

I would like to create a filter such as NOT BETEEN 0 AND 6, is this possible?

thx

wd60622 commented 7 months ago

Using a ~ on a Field negates the implemented between.

For example,

Query.from_("table").where(~Field("column").between(0, 6)).select("*")

results in

SELECT * FROM "table" WHERE NOT "column" BETWEEN 0 AND 6

Does that fit your use-case?

info-rchitect commented 7 months ago

Functionally this will work, thanks again.

wd60622 commented 5 months ago

If this helped, feel free to close the issue

info-rchitect commented 5 months ago

It did indeed help, ty!