---
url: /card-guides/sql-table.md
description: >-
  The SQL Table card component is a powerful tool that fetches data directly
  from a database rather than from a MODLR Cube.
---

# SQL Table

The SQL Table card component is a powerful tool that fetches data directly from a database rather than from a MODLR Cube. Text elements must be used to display the fetched data.

## Common Use Properties

**Columns Property**
The number of columns in the table. *Limit: 40*

**Query Property**
The SQL Query to be ran.

**Query Parameters Property**
Only use if the SQL query entered in the Query Property is paramaterized with ?

* **Example:** `select * from financial_transactions where id = ?`\
  If so, then add as many items as there are ? parameters and enter the values accordingly (in order of ? appearance).

**Datasource Property**
The database to run the query in.

**Row Limit Property**
The maximum number of rows to be displayed.

**SQL Formulas to fetch Data in Text Components**
Once an SQL table has been created there are several formulas that can be used within text elements to fetch data from the table.

* `SQLCOLUMNNAME(column)`: Returns the name of the field for the specified column index in a cards SQL Table component.
* `SQLROW()`: Returns the entire row as a comma-delimited string in a cards SQLTable component.
* `SQLCOLUMN(column)`: Returns the column value of the current row in a cards SQLTable component. The column argument can either be the column index or the name for the current row.
* `SQLVALUE(row, column)`: Returns the value of a specific column from a specific row in a cards SQL Table component.

Components placed inside the table can also read [SQL Table Reserved Variables](/technical/reserved-variables#sql-table) - `colcount`, `table-row` and `row-list-size`. This is a smaller, distinct set from the [Table & Grid](/technical/reserved-variables#table-grid) components - SQL Table doesn't get `context-${dimension}` or the rest of the Card-wide variables, since it pulls from a datasource rather than a Cube.
