SQL.MySQL.InsertID
------------------

For MySQL Connection queries the last insert ID.

| Component | Version | macOS | Windows | Linux | Server | iOS SDK |
|---|---|---|---|---|---|---|
| [SQL](component_SQL.md) | [2.9](newinversion29.md) | ✅ Yes | ✅ Yes | ✅ Yes | ✅ Yes | ✅ Yes |

MBS( "SQL.MySQL.InsertID"; Connection ) 

**MBS**( **"SQL.MySQL.InsertID";** /\* For MySQL Connection queries the last insert ID. \*/  
**$Connection**) /\* The connection reference number gained with [SQL.NewConnection](SQLNewConnection.md). \*/ 

### Parameters

| Parameter | Description | Example |
|---|---|---|
| Connection | The connection reference number gained with [SQL.NewConnection](SQLNewConnection.md). | $Connection |

### Result

Returns the ID or error message.

### Description

For MySQL Connection queries the last insert ID.  
Please query value right after doing Insert. This value is reset when you call commit.  
This needs columns with AUTO\_INCREMENT.  
  
see also  
<http://dev.mysql.com/doc/refman/5.1/en/mysql-insert-id.html>  
### See also

- [SQL.NewConnection](SQLNewConnection.md)

### Blog Entries

- [Insert and return new record ID](https://www.mbsplugins.de/archive/2024-06-27/Insert_and_return_new_record_I/monkeybreadsoftware_blog_filemaker)
- [MBS Filemaker Plugin, version 2.9pr6](https://www.mbsplugins.de/archive/2012-09-03/MBS_Filemaker_Plugin_version_2/monkeybreadsoftware_blog_filemaker)

This function is free to use.

Created 18th August 2014 , last changed 10th June 2026

  
[SQL.ListConnections](SQLListConnections.md) - [SQL.NewCommand](SQLNewCommand.md)

[HTML Version](SQLMySQLInsertID.shtml)