Start learning with our library of video tutorials taught by experts. Get started
Viewers: in countries Watching now:
MySQL is by far the most popular database management system for small- to medium-sized web projects. In this course, Bill Weinman provides clear, concise tutorials that guide you through creating and maintaining a MySQL database of your own. Bill explores the basic syntax, using SQL statements to create, insert, update, and delete data from your tables. He also covers creating a new database from scratch, as well as data types, transactions, subselects, views, and stored routines. Plus, learn about the multi-platform PHP PDO interface that will help you connect your database to web applications.
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.
And press add album you'll notice that here is this form and it is pulled up this new inserted record and populated the form. And you'll notice that happens here with this fetch_album id call. And then we can add tracks and we can edit it, change it around and what have you. And then I can come back here and I can delete it if I want to. And this all happens because I'm able to keep track of that ID when I insert that new record in the database.
So MySQL's last insert ID function provides the value. Of the most recently generated auto-increment column, this is very useful and often necessary for creating relational database applications.
There are currently no FAQs about MySQL Essential Training.
Access exercise files from a button right under the course name.
Search within course videos and transcripts, and jump right to the results.
Remove icons showing you already watched videos if you want to start over.
Make the video wide, narrow, full-screen, or pop the player out of the page into its own window.
Click on text in the transcript to jump to that spot in the video. As the video plays, the relevant spot in the transcript will be highlighted.