FM.SQL.Field
------------

Queries field value for given position in result.

| Component | Version | macOS | Windows | Linux | Server | iOS SDK |
|---|---|---|---|---|---|---|
| [FM](component_FM.md) [FMSQL](component_FMSQL.md) | [5.1](newinversion51.md) | ✅ Yes | ✅ Yes | ✅ Yes | ✅ Yes | ✅ Yes |

MBS( "FM.SQL.Field"; SQLref; Row; Column { ; Flags } ) 

**MBS**( **"FM.SQL.Field";** /\* Queries field value for given position in result. \*/  
**$SQLref**; /\* The reference number returned by [FM.SQL.Execute](FMSQLExecute.md) function. \*/   
**$Row**; /\* The row number from 0 to [FM.SQL.RowCount](FMSQLRowCount.md)-1. \*/   
**$Column**; /\* The column number from 0 to [FM.SQL.FieldCount](FMSQLFieldCount.md)-1.e.g. $col \*/   
**$Flags**) /\* Optional; Various flags.  
Pass 0 to return value as it is. (default)  
Pass 1 to return file name of a container field.  
Pass 2 to return container data base64 encoded.e.g. 0 \*/ 

### Parameters

| Parameter | Description | Example | Flags |
|---|---|---|---|
| SQLref | The reference number returned by [FM.SQL.Execute](FMSQLExecute.md) function. | $SQLRef |  |
| Row | The row number from 0 to [FM.SQL.RowCount](FMSQLRowCount.md)-1. | $row |  |
| Column | The column number from 0 to [FM.SQL.FieldCount](FMSQLFieldCount.md)-1. | $col |  |
| Flags | Various flags.   Pass 0 to return value as it is. (default)   Pass 1 to return file name of a container field.   Pass 2 to return container data base64 encoded. | 0 | Optional      Added in version **12.1**. |

### Result

Returns value or error.

### Description

Queries field value for given position in result.  
Native data type is preserved so this function can returns text, number, time, date, timestamp and container.  
### Examples

Query field values:

 Set Variable \[$sql ; Value:MBS ( "[FM.SQL.Execute](FMSQLExecute.md)"; ""; "select \* from Clients")\]  
\# query first field of first row:   
Set Variable \[$value ; MBS ( "FM.SQL.Field"; $sql ; 0; 0 ) \]  
\# query other field   
Set Variable \[$value ; MBS ( "FM.SQL.Field"; $sql ; $row ; $col ) \]  
Set Variable \[$r ; MBS ( "[FM.SQL.Release](FMSQLRelease.md)"; $sql ) \]  
### See also

- [FM.SQL.CSV](FMSQLCSV.md)
- [FM.SQL.Execute](FMSQLExecute.md)
- [FM.SQL.FieldCount](FMSQLFieldCount.md)
- [FM.SQL.FieldType](FMSQLFieldType.md)
- [FM.SQL.Release](FMSQLRelease.md)
- [FM.SQL.RowCount](FMSQLRowCount.md)
- [FM.SQL.Text](FMSQLText.md)
- [FM.SQL.XMLRecords](FMSQLXMLRecords.md)
- [SQL.Execute](SQLExecute.md)
- [SQL.FieldCount](SQLFieldCount.md)

### Release notes

- **Version 13.2**
    - Fixed [FM.SQL.Field](https://www.mbsplugins.eu/FMSQLField.shtml) function to handle flags better.
    - Fixed [FM.SQL.Field](https://www.mbsplugins.eu/FMSQLField.shtml) function to return a name if there is no FNAM stream.
- **Version 12.1**
    - Added flags to [FM.SQL.Field](https://www.mbsplugins.eu/FMSQLField.shtml) function to return containers as base64 or just their file name.

### Example Databases

- [DynaPDF/Extract Images](https://www.mbsplugins.eu/MBS-FileMaker-Plugin-Examples/DynaPDF/Extract%20Images.shtml#13033FieldAnchor_)
- [SQL in FileMaker/ImageGallery](https://www.mbsplugins.eu/MBS-FileMaker-Plugin-Examples/SQL%20in%20FileMaker/ImageGallery.shtml#1CustomFunctionAnchor_)
- [SQL in FileMaker/SQL Select Container](https://www.mbsplugins.eu/MBS-FileMaker-Plugin-Examples/SQL%20in%20FileMaker/SQL%20Select%20Container.shtml#1ScriptAnchor_)
- [SQL to other databases/SQL Export](https://www.mbsplugins.eu/MBS-FileMaker-Plugin-Examples/SQL%20to%20other%20databases/SQL%20Export.shtml#1ScriptAnchor_)

### Blog Entries

- [MBS FileMaker Advent calendar - Door 7 - Precise entries and their types](https://www.mbsplugins.de/archive/2025-12-07/MBS_FileMaker_Advent_calendar_/monkeybreadsoftware_blog_filemaker)
- [Data structures in MBS Plugin](https://www.mbsplugins.de/archive/2023-11-27/Data_structures_in_MBS_Plugin/monkeybreadsoftware_blog_filemaker)
- [MBS FileMaker Plugin, version 13.2pr4](https://www.mbsplugins.de/archive/2023-04-25/MBS_FileMaker_Plugin_version_1/monkeybreadsoftware_blog_filemaker)
- [Sending email with a huge custom function](https://www.mbsplugins.de/archive/2021-06-26/Sending_email_with_a_huge_cust/monkeybreadsoftware_blog_filemaker)
- [FileMaker records to XML or JSON](https://www.mbsplugins.de/archive/2020-06-30/FileMaker_records_to_XML_or_JS/monkeybreadsoftware_blog_filemaker)
- [Image Gallery in FileMaker using SQL](https://www.mbsplugins.de/archive/2018-05-09/Image_Gallery_in_FileMaker_usi/monkeybreadsoftware_blog_filemaker)
- [FileMaker Custom function to query a value from other table or file](https://www.mbsplugins.de/archive/2017-02-10/FileMaker_Custom_function_to_q/monkeybreadsoftware_blog_filemaker)
- [MBS FileMaker Plugin, version 6.0pr6](https://www.mbsplugins.de/archive/2016-01-13/MBS_FileMaker_Plugin_version_6/monkeybreadsoftware_blog_filemaker)
- [Execute SQL in FileMaker and get back native field types](https://www.mbsplugins.de/archive/2015-04-18/Execute_SQL_in_FileMaker_and_g/monkeybreadsoftware_blog_filemaker)

### FileMaker Magazin

- [Ausgabe 3/2018, Seite 34](https://filemaker-magazin.de/neuigkeit/3953-Appetithappen-FMM_201803)

This function checks for a license.

Created 18th April 2015 , last changed 5th September 2025

  
[FM.SQL.Execute](FMSQLExecute.md) - [FM.SQL.FieldCount](FMSQLFieldCount.md)

[HTML Version](FMSQLField.shtml)