# Problem with "like" in filters

**URL:** <https://community.dreamfactory.com/t/problem-with-like-in-filters/4687>\
**Category:** REST API\
**Created:** [November 10, 2018, 7:46pm UTC](https://community.dreamfactory.com/t/problem-with-like-in-filters/4687 "2018-11-10T19:46:42Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![jsolbrig](https://avatars.discourse-cdn.com/v4/letter/j/b9bd4f/32.png) [@jsolbrig](https://community.dreamfactory.com/u/jsolbrig)\
**Post date:** [November 10, 2018, 7:46pm UTC](https://community.dreamfactory.com/t/problem-with-like-in-filters/4687/1 "2018-11-10T19:46:42Z")

</div>

When using “like” in a filter I am getting odd results when the pattern starts with “%” and the match starts with the first character in the string. For example, if:

1. My filter looks like “filter=region like %BayArea%”
2. The database contains one record whose “region” field contains “BayArea Denver”

the record is not returned in a “get” request. However, if my filter looks like “filter=region like BayArea%” the record is returned as expected.

This seems like it goes against the SQL definition for % where % is supposed to match zero, one, or more characters. Here it seems that % matches one or more, but not zero.

---

<div class="post-metadata">

**Author:** ![Erik\_Jacobsen](https://yyz1.discourse-cdn.com/flex035/user_avatar/community.dreamfactory.com/erik_jacobsen/32/1132_2.png) [@Erik\_Jacobsen](https://community.dreamfactory.com/u/Erik_Jacobsen)\
**Post date:** [November 12, 2018, 5:12pm UTC](https://community.dreamfactory.com/t/problem-with-like-in-filters/4687/2 "2018-11-12T17:12:12Z")

</div>

Hi @jsolbrig

[https://wiki.dreamfactory.com/DreamFactory/Features/Database/Records#Filter\_Strings](https://wiki.dreamfactory.com/DreamFactory/Features/Database/Records#Filter_Strings) based on the docs, both should be supported.

[![CloudApp](https://d2ddoduugvun08.cloudfront.net/items/1N3A36130S3u2T3D3q0v/Image%202018-11-12%20at%207.47.51%20AM.png "Image 2018-11-12 at 7.47.51 AM.png") ](https://cl.ly/8360181a4494)

I ran a couple of examples and see that it is working correctly.

Dreamfactory Instance:  
[![CloudApp](https://d2ddoduugvun08.cloudfront.net/items/2m3E333r2S0J3H451M37/Image%202018-11-12%20at%208.24.14%20AM.png "Image 2018-11-12 at 8.24.14 AM.png") ](https://cl.ly/e71ee0bc0206)

[![CloudApp](https://d2ddoduugvun08.cloudfront.net/items/2g1U2S33272x3f3j3Y0s/Image%202018-11-12%20at%209.08.36%20AM.png "Image 2018-11-12 at 9.08.36 AM.png") ](https://cl.ly/9fabe3a281a1)

Example of returning zero records:  
[![CloudApp](https://d2ddoduugvun08.cloudfront.net/items/0J0L0X320Q3N1b17023J/Image%202018-11-12%20at%209.11.35%20AM.png "Image 2018-11-12 at 9.11.35 AM.png") ](https://cl.ly/4f4f90fd9976)

Insomnia:  
[![CloudApp](https://d2ddoduugvun08.cloudfront.net/items/1x3N3E3I1g0E2I0L0k40/Image%202018-11-12%20at%207.59.29%20AM.png "Image 2018-11-12 at 7.59.29 AM.png") ](https://cl.ly/b717cefdbe09)

[![CloudApp](https://dxc4e0vr313yq.cloudfront.net/production/t/86e5e7627871/h200 "Image 2018-11-12 at 8.00.01 AM.png") ](https://cl.ly/86e5e7627871)

The designation of %ANY\_STRING% in Dreamfactory is meant to work for contains, not specifically zero, one or more, but just the recognition that the string is, in fact, present as a match.

I don’t suppose you have a snippet of schema you could send over for us build out in our test database and to do some other testing against? If not, we can try to recreate something to do further testing.

For what it is worth, we are using for our testing:  
[![CloudApp](https://d2ddoduugvun08.cloudfront.net/items/3q1x3O3C2o1B2A2i0L2E/Image%202018-11-12%20at%208.21.23%20AM.png "Image 2018-11-12 at 8.21.23 AM.png") ](https://cl.ly/774088383b57)
