Arcade: SQL Filter - Fields w/Apostrophes and Parentheses?

490
1
Jump to solution
12-06-2023 07:03 AM
ArmstKP
Frequent Contributor

Here is my SQL filter statement that fails/errors.  Both field names (Name_Primary and PARK_NAME) have apostrophes and parentheses in them.  How would I form this statement to escape those characters?

 

var results = Filter(athleticfields, "Name_Primary = '"+$feature.PARK_NAME+"')

0 Kudos
1 Solution

Accepted Solutions
KenBuja
MVP Esteemed Contributor

You can substitute a Arcade variable in the sql statement like this

var Park_Name = $feature.PARK_NAME;
var results = Filter(athleticfields, "Name_Primary = @Park_Name");

In my testing, this was able to filter attributes that contain apostrophes and parenthesis.

View solution in original post

1 Reply
KenBuja
MVP Esteemed Contributor

You can substitute a Arcade variable in the sql statement like this

var Park_Name = $feature.PARK_NAME;
var results = Filter(athleticfields, "Name_Primary = @Park_Name");

In my testing, this was able to filter attributes that contain apostrophes and parenthesis.