Skip to content

How to do union/unionAll with order for different queries? #586

Closed
@ktalebian

Description

@ktalebian

I can do the following:

 SqlBuilder.select(columName)
            .from(tableName)
            .where(userId, isEqualTo(id))
            .and(type, isEqualTo("type1"))
            .unionAll()
            .select(columnName)
            .from(tableName)
            .where(userId, isEqualTo(id))
            .and(type, isEqualTo("type2"));

However, I need to do an orderBy and a limit on each queries individually. If I add a .orderBy().limit() then I cannot do a .unionAll

How do I achieve this then?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions