QuickList.AddSQL
----------------

Adds values to a quick list via SQL.

| Component | Version | macOS | Windows | Linux | Server | iOS SDK |
|---|---|---|---|---|---|---|
| [List](component_List.md) | [5.1](newinversion51.md) | ✅ Yes | ✅ Yes | ✅ Yes | ✅ Yes | ✅ Yes |

MBS( "QuickList.AddSQL"; ListRef; SQL Statement; FileName { ; Params... } ) 

**MBS**( **"QuickList.AddSQL";** /\* Adds values to a quick list via SQL. \*/  
**$ListRef**; /\* The reference to the list returned from [QuickList.New](QuickListNew.md) function.e.g. $List \*/   
**$SQL Statement**; /\* SQL Statement as a Text string \*/   
**$FileName**; /\* The target database name. Can be empty to not limit query to one database.e.g. "" \*/   
**$Params...**) /\* Optional; Optional, pass here parameters. One parameter to this function for each parameter you want to pass to the SQL statement.e.g. 123 \*/ 

### Parameters

| Parameter | Description | Example | Flags |
|---|---|---|---|
| ListRef | The reference to the list returned from [QuickList.New](QuickListNew.md) function. | $List |  |
| SQL Statement | SQL Statement as a Text string |  |  |
| FileName | The target database name. Can be empty to not limit query to one database. | "" |  |
| Params... | Optional, pass here parameters. One parameter to this function for each parameter you want to pass to the SQL statement. | 123 | Optional |

### Result

Returns number of items added or error.

### Description

Adds values to a quick list via SQL.  
All values in the result set are added as text to the list.  
Returns error in case of SQL error with error message.  
  
This function is currently only supported for FileMaker 11 and newer. If you need it for older versions, please contact us.  
  
This function takes variable number of parameters. Pass as much parameters as needed separated by the semicolon in FileMaker.  
Please repeat Params parameter as often as you need.  
### Examples

Fill a list and return it:

 # create new list   
Set Variable \[ $list ; Value: MBS ("[QuickList.New](QuickListNew.md)") \]  
\# add values via SQL   
Set Variable \[ $r ; Value: MBS ("QuickList.AddSQL"; $list ; "SELECT TextField FROM \\"Test Table\\"")\]  
\# query list content for displaying   
Set Variable \[ $text ; Value: MBS ("[QuickList.GetList](QuickListGetList.md)"; $list ) \]  
\# and free it   
Set Variable \[ $r ; Value: MBS ("[QuickList.Release](QuickListRelease.md)"; $list )\]  
Add values based on SQL query in current file and one parameter:

 MBS ("QuickList.AddSQL"; "12002"; "SELECT TextField FROM \\"Test Table\\" WHERE NumberField&gt;?"; Get(Filename); 1 )  
Run query with quoted names and parameters for value:

 Set Variable \[ $Text ; Value: MBS ("QuickList.AddSQL"; $ListNum ; "SELECT \\"MyField\\" from \\"MyTable\\" Where \\"SomeField\\" = ?"; Get(FileName); "xyz") \]  
### See also

- [QuickList.AddList](QuickListAddList.md)
- [QuickList.GetList](QuickListGetList.md)
- [QuickList.New](QuickListNew.md)
- [QuickList.Release](QuickListRelease.md)

### Blog Entries

- [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 5.1pr1](https://www.mbsplugins.de/archive/2015-03-16/MBS_FileMaker_Plugin_version_5/monkeybreadsoftware_blog_filemaker)

This function checks for a license.

Created 12nd March 2015 , last changed 25th February 2026

  
[QuickList.AddQuickList](QuickListAddQuickList.md) - [QuickList.AddValue](QuickListAddValue.md)

[HTML Version](QuickListAddSQL.shtml)