Forum Discussion

benassi's avatar
benassi
Helper
7 years ago

LIQL not in query

Hi,

 

I was wondering is it possible to do something like the following. Basically i want to exclude a set of id's from the result

 

// get a 604 response

SELECT * FROM messages WHERE id != '1'

 

// couldn't find anything in the docs that support this

SELECT * FROM messages WHERE id NOT IN ('1, '2')

 

Cheers

  • benassi - 

     

    Not operator is not supported in lithium LIQL.  You need to check using freemarker <#if> <#else> condition.

     

     

    • benassi's avatar
      benassi
      Helper

      Thanks for the quick response.

       

      I don't know alot about LIQL, freemarker but this needs to be called via the API from an external source. 

       

      Am i correct that freemarker wouldn't work in this scenario?

       

      Cheers

      • benassi - 

         

        Yes, freemarker wouldn't work in this scenario. However, this can be done in any language. 

         

        e.g you need to fetch messages expect 13. 

         

        SELECT * FROM messages

         

        if( msg.id != 13){
          //Do something here
        }

        Also, if this case is only for few messages e.g 10,20. You can use where in query.  

        SELECT * FROM messages where id in ('1','2','3' and so on)