influxdata / influxdata/influxdb-java

How to use andNested () to generate SQL composed of multiple brackets

Open
#681 1 comment 0 reactions 1 assignee Claimed by @bednar View on GitHub
question
Dominant language
Java
Stars
1.2k
Forks
469
PR merge metrics
No merged PRs in 30d

Description

### I want to get a statement like this:

`SELECT * FROM flow WHERE ((ipValue <= 100 AND ipValue >= 200) OR (ipValue <= 300 AND ipValue >= 400)) AND value < 200`

### But I found that the api can only be written like this:

```java
WhereQueryImpl query = select()
.from("flow", getFullyMeasurement(param.getRp(), param.getTableName()))
.where();

query.andNested().and(lte("ipValue", 100))
.and(gte("ipValue", 200)).close();
query.orNested().and(lte("ipValue", 300))
.and(gte("ipValue", 400)).close();
query.and(lt("value", 200));
```

### result

`SELECT * FROM flow WHERE (ipValue <= 100 AND ipValue >= 200) OR (ipValue <= 300 AND ipValue >= 400) AND value < 200`

**How can I generate this form of sql:**

`((ipValue <= 100 AND ipValue >= 200) OR (ipValue <= 300 AND ipValue >= 400))`

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.