Improving this table
If I'm reading you right, the function of Next_Id is to group the entries into ordered sets.  The way you've done it is the way an old fashioned network database would have done it.  Each next_id "points to" another entry.

The relational model groups items into (unordered) sets by putting a common value in a foreign key.  I don't have a model for your data, so I'll take a blind stab at a design.  We use the Id of the first entry in the set to identify the group membership.  The first entry doesn't have a null, instead, it points to itself.

Now, the table looks like this:

Id       Table_Name         Table_Id        Set_Id
1        Login              1               1
2        Logout             10              1
3        Close              2               1
4        Open               3               1
5        Login              4               5
6        Login              3               6
7        Logout             4               6
8        Close              9               6
9        Login              2               9
10       Logout             3               9


(I fixed the presumed bug in row 9).

This offers one advantage at storage time:  The set membership is known when a new value is inserted.  The next_id is not known, because the next event hasn't happened yet.  This means you only have to store it once, instead of storing it once and then updating it when the Next _id changes from NULL to something else.

It also offers an advantage at retrieval time.  Once you figured out the Set_id you are looking for, you can get all the members with a single trip to the database,  using something like this:

select *
from mytable
where set_id = somevalue
order by Id


I have guessed at the correct order for the retrieved set, based on the idea that later events will have a higher id.  But I don't know that that's true in your case.

If this select runs too slow, you could consider adding an index on Set_id.

A better solution would require knowing more about your data and your process.  Hope this helps.