From the reference libraryFiveM

RawExecute

ox/oxmysql/Functions/rawExecute.mdx

RawExecute

rawExecute can be used to execute frequently called queries faster and accepts multiple sets of parameters to be used with a single query.

  • Date will not return the datestring commonly used in FiveM
  • TINYINT 1 and BIT will not return a boolean
  • You can only use ? value placeholders, ?? column placeholders and named placeholders will throw an error

Unlike prepare, the SELECT statement will always return an array of rows. When using SELECT, the return value will match query, single, or scalar depending on the number of columns and rows selected.

Promise

    local response = MySQL.rawExecute.await('SELECT `firstname`, `lastname` FROM `users` WHERE `identifier` = ?', {
        identifier
    })

    print(json.encode(response, { indent = true, sort_keys = true }))
    ```

  
  

    ```js
    const response = await MySQL.rawExecute('SELECT `firstname`, `lastname` FROM `users` WHERE `identifier` = ?', [
      identifier
    ])

    console.log(JSON.stringify(response))
    ```

  

**Aliases**

- `exports.oxmysql.rawExecute_async`

## Callback

```lua
    MySQL.rawExecute('SELECT `firstname`, `lastname` FROM `users` WHERE `identifier` = ?', {
        identifier
    }, function(response)
        print(json.encode(response, { indent = true, sort_keys = true }))
    end)
    ```

  
  

    ```js
    MySQL.rawExecute('SELECT `firstname`, `lastname` FROM `users` WHERE `identifier` = ?', [
      identifier
    ], (response) => {
      console.log(JSON.stringify(response))
    })
    ```

  

**Aliases**

- `exports.oxmysql.rawExecute`
Back to documentation