Skip to content

Tag: sql

How to query and filter relation entity in room database

For example: User: Post: Data if i use SELECT * FROM user i got the desire data(a user and all posts), but how can i filter the post for a specific type, like WHERE post.type = ‘sth’ is that possible? Answer but how can i filter the post for a specific type, It depends on exactly what you want to

Oracle – get previous, current and next year from query [closed]

Closed. This question is opinion-based. It is not currently accepting answers. Want to improve this question? Update the question so it can be answered with facts and citations by editing this post. Closed last year. Improve this question Is below example good solution for get previous, current and next year?…

Flag “yes/No” if the subsequent row has same ID

I have data like this. If the same id is present in the next row, I want to flag as Yes. If it is not present then Make it as ‘No’. Can you kindly help me with the query? Thanks Answer The problem with multiple rows for the same ID and no other column that can be used to futher

sql prevent double booking with trigger

I am stumbled on constructing a DB table for hotel reservations. In my reservation db, there is a reservation start_datetime and end_datetime attribute to indicate booked period and I tried to prevent double booking with a trigger statemen, but I am certain that this method would be vulnerable to race conditi…

How do I get to choose MAX value by result of column?

I have this simple Table about chat Item I have my query that gets latest entered chat by chatId item as follow Now I would like to get latest item with isDone = 0 as priority. If any of result row has isDone = 0, it will get MAX(ID) with isDone = 0. If not, it will get the MAX(ID)