Forum Discussion

fctester123456's avatar
7 years ago

LIQL: using query result as in condition for another

is there any way to use result from first query as condition in second query. e.g. select id from boards where parent_category.id ='xxxxx' this query return id list : aaa ,bbb ,ccc   i want to g...
  • TariqHussain's avatar
    7 years ago

    fctester123456- You cannot run the nested query inside in LIQL. However, you can generate strings from the first query which can be used inside the second query.

     

    e.g ('board-id1', 'board-id-2')

     

     

    <#assign boardsQuery =restadmin("2.0","/search?q=" + "SELECT * FROM boards"?url).data.items />
    
    <#assign boardIDs = "" />
    <#list boardsQuery as board>
      <#if (board?index + 1) == userid?size>
            <#assign boardIDs = boardIDs+ "'" + board.id + "'" />
      <#else>
            <#assign boardIDs = boardIDs+ "'" + board.id + "'" +"," />
      </#if>
    </#list>

    The above query will return you string  'board-id1', 'board-id-2' which further can be used in the second query.

     

     

    <#assign messagesQuery =restadmin("2.0","/search?q=" + "SELECT * FROM messages where board.id in ( ${boardIDs} ) "?url).data.items />