Skip to main content
Known Participant
Aug 17, 2022 8:39 AM UTC
Question

How to write this sql command in appian rules

select * from Table where column1= value1 and column2= value2 and ( column3= value3 or column4 = value4)

I need to query above sql command into appian query. How can I write? Can anyone help me with this please.

    3 replies

    Inspiring
    Aug 17, 2022 8:53 AM UTC

    you have to use nested querylogicalExpression to do this.

    a!queryEntity(
      entity: cons!UAS_DSE,
      query: a!query(
        pagingInfo: a!pagingInfo(1,-1),
        logicalExpression: a!queryLogicalExpression(
          operator: "AND",
          filters:{
            a!queryFilter(
              field: "accountid", /*COLUMN1*/
              operator: "=",
              value: "VU28682"
            ),
    
            a!queryFilter(
              field: "accountname", /*COLUMN2*/
              operator: "=",
              value:"THE 2012 RECKLING GREAT GRANCHILDREN'S TRUST DTD 12/3/2012 FOR LUKE JORNAYVAZ"
            )
          },
          logicalExpressions: a!queryLogicalExpression(
            operator: "OR",
            filters: {
              a!queryFilter(
                field: "status", /*COLUMN3*/
                operator: "=",
                value:"Categorize New Holding"
              ),
    
              a!queryFilter(
                field: "processId", /*COLUMN4*/
                operator: "=",
                value:536877759
              )
            }
          )
        )
      )
    ).data

    Known Participant
    Aug 17, 2022 12:31 PM UTC

    Thanks

    harshitb6843
    Brainy
    Aug 17, 2022 9:02 AM UTC

    Use the query editor from the toolbar to apply all these filters visually and then check the rule Appian generates for you to understand how queries are configured using a!queryEntity()