sql - Select rows whose IDs are not found in another table under certain constraints -


The practical problem I am solving is to display a list of items that have recently been updated. Which the user has not seen recently.

I am attempting to return a table containing items that are not in the item view table for a given user (we use the user number 1 it is said). I came up with:

  from SELECT * items where i.updated_at & gt; Date_sub (curdate), interval 10 days) and not i.id (select items from item_id in items_views where i.created_at> date_sub (curdate), interval 10 days) and i.user_id = 1)  

It works fine (is it the best way to do this too?). However, I am considering the item which is considering the item which was viewed 8 days earlier and was updated 3 days earlier. One such item is clearly new, but it will not be shown under this question. How should I be involved in linking this restriction?

If you have the update_at column in your view, then you can always add checks to make sure There is a line that the up-to-date date is not within your timeline. Better yet you can check to make sure that your up-to-date date is more than your last seen date.


Comments

Popular posts from this blog

Eclipse CDT variable colors in editor -

AJAX doesn't send POST query -

wpf - Custom Message Box Advice -