From the reference libraryFiveM

insert

ox/oxmysql/Functions/insert.mdx

insert

Inserts a new entry into the database and returns the insert id for the row, if valid.

Promise

    local id = MySQL.insert.await('INSERT INTO `users` (identifier, firstname, lastname) VALUES (?, ?, ?)', {
        identifier, firstName, lastName
    })

    print(id)
    ```

  
  

    ```js
    const id = await MySQL.insert('INSERT INTO `users` (identifier, firstname, lastname) VALUES (?, ?, ?)', [
      identifier, firstName, lastName
    ])

    console.log(id)
    ```

  

**Aliases**

- `MySQL.Sync.insert`
- `exports.ghmattimysql.executeSync`
- `exports.oxmysql.insert_async`

## Callback

```lua
    MySQL.insert('INSERT INTO `users` (identifier, firstname, lastname) VALUES (?, ?, ?)', {
        identifier, firstName, lastName
    }, function(id)
        print(id)
    end)
    ```

  
  

    ```js
    MySQL.insert('INSERT INTO `users` (identifier, firstname, lastname) VALUES (?, ?, ?)', [
      identifier, firstName, lastName
    ], (id) => {
      console.log(id)
    })
    ```

  

**Aliases**

- `MySQL.Async.insert`
- `exports.ghmattimysql.execute`
- `exports.oxmysql.insert`
Back to documentation