Answer the question
In order to leave comments, you need to log in
What is the best way to filter data?
There is a news feed, new ones are added every day. A person comes in and reads, we save the news he read to the database.
Question: how, in this case, is it more efficient and more correct to filter the news by "read / not read". Now each read news is recorded in the database, and the unread ones are selected like this:
select * from news where id not in (select id from viewed)
Answer the question
In order to leave comments, you need to log in
UPDATE TABLE usersSettings SET lastViewed=NOW() WHERE userID = ...;
SELECT * FROM news WHERE newsTime > (SELECT lastViewed FROM usersSettings WHERE userID = ...) ;
Maybe something like this.
"a lot" is how much? If we are not talking about millions, then it will go.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question