Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
CODE PROJECT For Those Who Code
  • Home
  • Articles
  • FAQ
Community
  1. Home
  2. Database & SysAdmin
  3. Database
  4. Selecting Recent row

Selecting Recent row

Scheduled Pinned Locked Moved Database
tutorialquestion
6 Posts 4 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • T Offline
    T Offline
    T RATHA KRISHNAN
    wrote on last edited by
    #1

    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?

    R C R 3 Replies Last reply
    0
    • T T RATHA KRISHNAN

      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?

      R Offline
      R Offline
      R Giskard Reventlov
      wrote on last edited by
      #2

      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

      T 1 Reply Last reply
      0
      • T T RATHA KRISHNAN

        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?

        C Offline
        C Offline
        Chris Meech
        wrote on last edited by
        #3

        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]

        1 Reply Last reply
        0
        • R R Giskard Reventlov

          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

          T Offline
          T Offline
          T RATHA KRISHNAN
          wrote on last edited by
          #4

          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?

          R 1 Reply Last reply
          0
          • T T RATHA KRISHNAN

            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?

            R Offline
            R Offline
            R Giskard Reventlov
            wrote on last edited by
            #5

            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

            1 Reply Last reply
            0
            • T T RATHA KRISHNAN

              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?

              R Offline
              R Offline
              Roger Wright
              wrote on last edited by
              #6

              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"

              1 Reply Last reply
              0
              Reply
              • Reply as topic
              Log in to reply
              • Oldest to Newest
              • Newest to Oldest
              • Most Votes


              • Login

              • Don't have an account? Register

              • Login or register to search.
              • First post
                Last post
              0
              • Categories
              • Recent
              • Tags
              • Popular
              • World
              • Users
              • Groups