Selecting Recent row
-
Hi! I've to select the most recently added field in a column. i.e the last value in a column. How to select it?
-
Hi! I've to select the most recently added field in a column. i.e the last value in a column. How to select it?
Do you mean to get the last row of data added to the table? Your question is not clear.
"If you think it's expensive to hire a professional to do the job, wait until you hire an amateur." Red Adair. nils illegitimus carborundum me, me, me
-
Hi! I've to select the most recently added field in a column. i.e the last value in a column. How to select it?
You could use a trigger to include a timestamp on each row that is inserted or updated. Then your select would be on the most recently timestamped row. However this may not work if your inserts and updates can occur faster than the smallest time span for your timestamp. :)
Chris Meech I am Canadian. [heard in a local bar] In theory there is no difference between theory and practice. In practice there is. [Yogi Berra]
-
Do you mean to get the last row of data added to the table? Your question is not clear.
"If you think it's expensive to hire a professional to do the job, wait until you hire an amateur." Red Adair. nils illegitimus carborundum me, me, me
I'll describe it. I'm inserting TeamIds to the table from one class(TeamIds are selected ids of a list in a Menu page). I've to display a color of the selected team(TeamID)over the remaining pages. On Clicking a button, I've stored the selected index of the list control(TeamID) to the Team table. From other pages(other classes), I've to query the recently added TeamID(last one in the table). How to do this?
-
I'll describe it. I'm inserting TeamIds to the table from one class(TeamIds are selected ids of a list in a Menu page). I've to display a color of the selected team(TeamID)over the remaining pages. On Clicking a button, I've stored the selected index of the list control(TeamID) to the Team table. From other pages(other classes), I've to query the recently added TeamID(last one in the table). How to do this?
Quick thought: why not add the id to the session and use that? Save a trip back to the db to fetch what you already have.
"If you think it's expensive to hire a professional to do the job, wait until you hire an amateur." Red Adair. nils illegitimus carborundum me, me, me
-
Hi! I've to select the most recently added field in a column. i.e the last value in a column. How to select it?
If you're using an autonumber field as a primary key, select on the MAX value of that field. Alternatively, get the number of rows in the main table and fetch the (N-1)th row.
"A Journey of a Thousand Rest Stops Begins with a Single Movement"