athulya jose
athulya jose

Reputation: 11

select query in room db kotlin?

I am building an android app.In that app we need to implement select query with where clause ,using kotlin.

@Query(value = "Select * from AddEntity where type= +'Bird'")
fun getAllbirdModule() : List<AddEntity>

we are try this code but it is not working.

Upvotes: 1

Views: 615

Answers (2)

Hamza Khan
Hamza Khan

Reputation: 1521

Try to pass type in function rather than using hardcode value in Query like this

@Query(value = "SELECT * from AddEntity WHERE type = :type")
fun getAllbirdModule(type: String) : List<AddEntity>

or remove + sign

@Query(value = "Select * from AddEntity where type='Bird'")
fun getAllbirdModule() : List<AddEntity>

Upvotes: 3

MikeT
MikeT

Reputation: 57063

Try :-

@Query(value = "Select * from AddEntity where type='Bird'")
fun getAllbirdModule() : List<AddEntity>

Upvotes: 0

Related Questions