Menu

Simple OQL Querry

xeylou
2023-11-15
2024-01-02
  • xeylou

    xeylou - 2023-11-15

    hi,

    i would like to gather pending user request callers emails using an OQL querry through the REST API

    i guess the OQL querry would be like so

    SELECT Person AS P JOIN UserRequest AS U ON P.id = U.caller_id WHERE U.status LIKE 'pending'
    

    in this json post message

    {
       "operation": "core/get",
       "class": "Person",
       "key": "SELECT Person AS P JOIN UserRequest AS U ON P.id = U.caller_id WHERE U.status LIKE 'pending'",
       "output_fields": "email"
    }
    

    however, i got this json error message

    {
        "code": 100,
        "message": "Error: Wrong format for Join clause (right hand), expecting an id - found 'caller_id' at 53 in 'SELECT Person AS P JOIN UserRequest AS U ON P.id = U.caller_id WHERE U.status LIKE 'pending'', expecting {id}, I would suggest to use ''"
    }
    

    i can gather person's email based on its id (example with the id 18 person)

    {
       "operation": "core/get",
       "class": "Person",
       "key": "SELECT Person WHERE id LIKE '18'",
       "output_fields": "email"
    }
    

    & i can gather pending UserRequests caller id

    {
       "operation": "core/get",
       "class": "UserRequest",
       "key": "SELECT UserRequest WHERE status LIKE 'pending'",
       "output_fields": "caller_id"
    }
    

    i would like to JOIN them to gather the Person email joining its id with the UserRequest caller_id

    maybe the way i want to do it is not the proper one

    thank you for helping me, have a good day :)

     
  • Jeffrey Bostoen

    Jeffrey Bostoen - 2023-11-15

    You need to switch the IDs in the JOIN clause around. Right part is always just something like "class.id"

    Try

    SELECT Person AS P JOIN UserRequest AS U ON U.caller_id = P.id WHERE U.status LIKE 'pending'
    
     
    • xeylou

      xeylou - 2024-01-02

      hi

      sorry for the late response...
      thank you for your fix, that was it!

      thank you very much, have a great day!

       
      👍
      1

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.