sql - Best way to get next row based on primary key of any row in a table with sequence -
i have table this
id name sequence -------------------------- 45 alex 1 22 john 2 2 philip 3 65 shine 4 356 stephy 5 35 tom 6
ok.. here when pass id 2 should row of shine
since that's next row based on sequence after philip (2)
which best solution?
does want?
select top 1 t.* table t sequence > @id order sequence;
Comments
Post a Comment