Skip to content

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

Open
@changechenhao

Description

@changechenhao

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:

WhereQueryImpl<SelectQueryImpl> 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))

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions