How to select rows from a table from other table key column value +1
Hi, I just went through a situation where there are 2 tables and I need a select rows from first table based on the key column of second table incremented by 1. For example: Table1: 1 hari 123 2 hari2 321 3 hari3 432 4 hari4 234 5 hari5 543 Table2: 1 hari 123 4 hari4 234 The result selection must display 2 and 5 i.e.. 2 hari2 321 5 hari5 543 Please share your answers. Thanks, Ram
You can just put that right into the JOIN criteria: SELECT * FROM dbo.Table1 AS t1 JOIN dbo.Table2 AS t2 ON
t1.ID +1 =
t2.ID; Now, that does act as a function on the column, so it may result in scans. Test it to be sure.