Custom Room SQL query

  Kiến thức lập trình

I have a query in room DAO, which finds stations based on characters.

@Query("""
    SELECT code, name
    FROM RoomStations 
    WHERE 
    :input IS NULL
    OR 
    LOWER(code) LIKE LOWER(:input)
    OR
    LOWER(name) LIKE LOWER(:input || '%')
    LIMIT 3
""")

it works fine, return what I need
I want it to look input in code first, if not found then check name, if found then skip name.

when input= BE
it returns

BAP- BELAPUR
BAY- BELLARY

WHAT I WANT IT TO DO

BE-BAREILLY

How Can I get this result

LEAVE A COMMENT