简体   繁体   中英

How to write and in one Compare in GOSU

I have a query below and need to combine the 2nd and 3rd.compare condition with 'AND' operator

var query = ii.join(InvoiceItem#PolicyPeriod)
        .compare(PolicyPeriod#Plan, Relop.NotEquals, xyzPlan)
        .compareIn(PolicyPeriod#ProdType, {Prod.TC_FREE, Prod.TC_UNIQ})
        .compareIn(PolicyPeriod#Elig,{OffElig.TC_Yes})

Second compareIn statement should be like below in SQL but do not know how to combine two variables in one compare with AND operator.

if ( prodtype in ('FREE','UNIQ') and Elig = 'YES')

Any Advice!!

You can use .and() method from the QueryAPI:

var query = ii.join(InvoiceItem#PolicyPeriod)
    .compare(PolicyPeriod#Plan, Relop.NotEquals, xyzPlan)
    .and(\and1 -> {
        and1.compareIn(PolicyPeriod#ProdType, {Prod.TC_FREE, Prod.TC_UNIQ})
        and1.compareIn(PolicyPeriod#Elig, {OffElig.TC_Yes})
    })

In the same manner, you can use .or() method or even combine and() and or() in one statement.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM