Would like to figure out how to better retrieve data from database without performance cost.
Plan as follows:
Select id from article table
;List<int> arr;
int x = arr.Count()
Select * from article_tbl where id = x
; Run query.Am I planning right? What is better way of retrieving data from database?
Thanks a lot
Try something like this - you can call it "ad-hoc" or wrap it up in a stored procedure:
-- get the "latest" ID from the "Article" latest
-- but you need to define *latest* by WHAT criteria?? A date?? The ID itself??
DECLARE @LastID INT
SELECT TOP 1 @LastID = ID
FROM dbo.Article
ORDER BY .......... -- order by date? id? what??
-- get the detail data for that ID from the "Article_tbl"
SELECT (list of columns)
FROM dbo.Article_tbl
WHERE ID = @LastID