--- title: "executeScalarQuery" description: "Executes a select query using the given connectionName (or the default connection it omitted) and returns the first scalar value from the resultset." --- # executeScalarQuery > Executes a select query using the given connectionName (or the default connection it omitted) and returns the first scalar value from the resultset. **This function is used by Ignition's Expression language.** ## Description :::note This function is only available in [Transaction Group Expression Items](sql-bridge-transaction-groups/understanding-transaction-groups/expression-items/expression-items.md) and [Expression Tags](tags/creating-memory-expression-and-query-tags/creating-memory-expression-and-query-tags.md). ::: ## Syntax `executeScalarQuery(query[, connectionName])` - Parameters - string **query** - The query to execute. - string **connectionName** - Optional. The name of the database connection. - Results - Value - The first value returned from the query. ## Examples For the following examples, suppose there was a table 'weights' that contained these values. | ProductCode | Quantity | Weight | |----|---|----| | BAN_002 | 380 | 3.243 | | BAN_010 | 120 | 9.928 | | APL_000 | 125 | 1.287 | | FWL_220 | 322 | 7.889 | ```python title="Code Snippet" executeScalarQuery("SELECT MAX(Quantity) FROM weights", "MySQLConnection") //would return 380 ``` ```python title="Code Snippet" executeScalarQuery("SELECT * FROM weights", "MySQLConnection") //would return a string "BAN_002" ```