Join Bill Weinman for an in-depth discussion in this video Implementing auto-increment IDs, part of MySQL Essential Training.
- View Offline
- Exercise Files
…When a new row is inserted into a table in a…relational database, you often need to know the value of the…id column for the new row so that it can be…used in another table or for interactive forums or other purposes.…MySQL provides a function called last insert id that…provides the most recently generated value of an auto-increment column.…For example, here in this insert album SQL function you…notice we have this simple query inserted into the album.…The question marks are for the parameters and those parameters are filled in here in…the execute call with title artist, label, and released.…
And then down here there's a call to lastInsertId.…It has a slightly different form for the.…Postgress database but it gets the last inserted ID.…It'll get the ID of this column after…it's been inserted into the database and that's returned.…It's eventually used in this album edit, function up here.…Which gets past that ID for building the Album Edit form.…And so, if I come out here to the…application and I insert a new album, 1 January 2014.…
- Writing queries
- Creating and updating databases and tables
- Using MySQL built-in functions
- Sorting and filtering data
- Updating tables with triggers
- Working with subselects and views
- Creating and using a stored function
Skill Level Beginner
PHP with MySQL Essential Trainingwith Kevin Skoglund14h 32m Beginner
1. Installing and Configuring the Test Environment
2. Basic Syntax
3. Creating a Database
4. MySQL Data Types
5. MySQL Functions
8. Subselects and Views
9. Stored Routines
10. PHP's PDO Interface with MySQL
- Mark as unwatched
- Mark all as unwatched
Are you sure you want to mark all the videos in this course as unwatched?
Take notes with your new membership!
Type in the entry box, then click Enter to save your note.
1:30Press on any video thumbnail to jump immediately to the timecode shown.