sql case/if..then statement in arangodb aql

1,460 views
Skip to first unread message

Kenneth McMillion

unread,
Jun 10, 2014, 12:29:30 PM6/10/14
to aran...@googlegroups.com
Hi is there a way to do a case statement in arangodb from the http api

Frank Celler

unread,
Jun 11, 2014, 1:18:49 PM6/11/14
to aran...@googlegroups.com
Does this Issue https://github.com/triAGENS/ArangoDB/issues/468 address your problem or do have something else in mind?

Kenneth McMillion

unread,
Jun 17, 2014, 3:21:51 PM6/17/14
to aran...@googlegroups.com
I think it will I will have to read further.into your link but what I was trying to do was convert  the pseudo  sql below to aql - I have a clients collection  that looks like this

{
    "client":"Mr Green",
    "mailing_address": {
    "line2": "",
    "line3": "",
    "state": "FL",
    "zip": "32810",
    "line1": "3225 efg AVE",
    "city": "ORLANDO"
  },
  "physical_address": {
    "line2": "",
    "line3": "",
    "state": "FL",
    "zip": "32815",
    "line1": "4567 abc AVE",
    "city": "ORLANDO"
  },
  
    }




{
    "client":"Mr Pink",
    "physical_address": {
    "line2": "",
    "line3": "",
    "state": "FL",
    "zip": "32810",
    "line1": "2378 eieio AVE",
    "city": "ORLANDO"
  }
}




in sql I could do something similar to this:

select client, address =
   case
      when mailing_address is null then physical_address
      else  mailing_address
from clients

Jan Steemann

unread,
Jun 18, 2014, 2:44:24 AM6/18/14
to aran...@googlegroups.com
Hi Kenneth,

I think you can use the ternary operator for this in AQL:

FOR c IN clients
RETURN {
client: c.client,
c.address: IS_NULL(c.mailing_address) ? c.physical_address :
c.mailing_address
}

Best regards
Jan
> --
> You received this message because you are subscribed to the Google
> Groups "ArangoDB" group.
> To unsubscribe from this group and stop receiving emails from it, send
> an email to arangodb+u...@googlegroups.com
> <mailto:arangodb+u...@googlegroups.com>.
> For more options, visit https://groups.google.com/d/optout.

Kenneth McMillion

unread,
Jun 18, 2014, 9:59:45 AM6/18/14
to aran...@googlegroups.com, j.ste...@triagens.de
Thank you I will give that a try
Reply all
Reply to author
Forward
0 new messages