SELECT Builder - a handy script that generates SQL query for you based on a find

Discussion created by TimDietrich on Apr 26, 2014

Have you ever performed a find in FileMaker and wondered what an equivalent SELECT statement would look like? Or maybe had the need to write a SELECT statement (for use with ExecuteSQL), and you knew how to perform the find, but weren't sure how to translate it into SQL?


To help with this, I've put together a script called "SELECT Builder." To use it, you simply add it to your database, perform a find, and run the script. When the script completes, it will display a SELECT statement that is equivalent to the find that you performed. It also puts the SELECT statement into a global variable, so that you can grab the SQL and use it in an ExecuteSQL call.


Here's a link to a very simple database that includes the SELECT Builder script: SELECT_Builder_Script_Demo.zip


The database was created using FileMaker's "Contacts" starter solution. It includes 500 contact records to help you experiment with it. (Don't worry, they're fake.)


To experiment, open the database, perform a find as you normally would, and then run the script. If you want to use the script in your own database, copy it from the demo database. The script uses variables only (no fields), so it should work without needing to make any modifications to it. Be sure to read the script header comment, which includes notes and a few "gotchas" that you should be aware of.


I hope you find the script to be useful.