2 Replies Latest reply on Sep 18, 2006 4:02 AM by Newsgroup_User

    Grab last database entry...

    Level 7
      I have seen many ways to do this and I have instituted a 'poor mans' way of
      doing it, but doesnt anyone know a complete method to be able to insert an
      entry into a database and then turnaround and grab the id key to pass along
      to the next page?

      I am seeking a way to do it with MySQL and MS SQL (if that make a
      difference) but using CF / SQL.

      Thanks.


        • 1. Re: Grab last database entry...
          Dan Bracuk Level 5
          select max(something) with a big enough where clause works on pretty well any db.
          • 2. Re: Grab last database entry...
            Level 7
            What I am refering to (and I may be wrong and you supplied the right answer)
            is this senerio.

            My user, demo, creates a project using a 2 step form.

            Step one:
            Fills in information such as project name, due date, client, and project
            type and clicks 'continue'.
            That information is inserted into the database (project table) and they are
            taken to another form to finish the project information.
            The second form captures the project_id (key and auto increment) that was
            just inserted and when the user completes the second form (upload images),
            it update the data in the project table.

            Currently I have it where the 2nd page queries the database for the last
            entry by that username (in this case: demo) and gets the project_id that
            way. However, I don't think it is the most effective way to do it.

            Thanks!