Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Room Database Query for not equal

I'm trying to build a query for Room DB that finds all items except for a specific id. Well, no luck so far. I've tried both != and <> and the id is still coning through.

Query examples:

@Query("SELECT * FROM <table name> WHERE _id!=:id AND team=:team")

@Query("SELECT * FROM <table name> WHERE _id<>:id AND team=:team")

Any help is greatly appreciated.

like image 976
Jonathan Perez Avatar asked May 25 '18 12:05

Jonathan Perez


1 Answers

Okay, so both != and <> do work for creating a Query where you want to exclude something that is not equal to the parameter that you're passing in. My issue was that I was running 2 separate queries concurrently and one of them need the id passed from the other. Changed the code to run one after the other finishes and all is good now.

Thanks again!

JP

like image 85
Jonathan Perez Avatar answered Sep 29 '22 01:09

Jonathan Perez