Answers.Body: <p>SQL doesn't support LIKE for integer fields. For something like membership type id I'm not even sure what it would mean unless you have 10 or more, and even then still not really meaningful.</p>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2016-07-20T23:08:40.450Z
Answers.Text: membership_type_id actually supports using the membership type name as well. Try the API explorer to see how it works.
Answers.UserDisplayName: sdragnev
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2016-07-21T03:05:55.583Z
Answers.Text: I saw there was another field membership_type. IDs are integers so it's kind of weird if an id query matches on a name/string. I'd expect to query on membership_type if I wanted string match.
Answers.UserDisplayName: Demerit
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2016-10-02T19:38:41.047Z
Answers.Text: That's a fairly new development for convenience's sake, but yeah, it's a little confusing. It applies for other similar fields as well, eg option_group_id.
Answers.UserDisplayName: sdragnev
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2016-07-19T22:10:44.443Z
Answers.LastActivityDate: 2016-07-19T22:10:44.443Z
Answers.UserDisplayName: Demerit
Answers.Body: <p>It seems it is working now in 2018 (have tried to find Relationships Type). Just put a search term (a word or part of something) in"LIKE" text area as <strong>%YourSearchTerm%</strong>  </p>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2018-07-17T09:44:36.920Z
Answers.LastActivityDate: 2018-07-17T09:44:36.920Z
Answers.UserDisplayName: yurg
Answers.Body: <p>Please use the following - </p>
  
  <p>For any integer you can use IN rather than Like </p>
  
  <pre><code>$result = civicrm_api3('Membership', 'get', array(
    'sequential' =&gt; 1,
    'membership_type_id' =&gt; array('IN' =&gt; array("General", "Student")),
  ));
  </code></pre>
  
  <p>If selecting string LIKE is used </p>
  
  <pre><code>$result = civicrm_api3('Membership', 'get', array(
    'sequential' =&gt; 1,
    'source' =&gt; array('LIKE' =&gt; "payment"),
  ));
  </code></pre>
  
  <p>I guess this helps!!!</p>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2016-07-20T12:57:58.313Z
Answers.LastActivityDate: 2016-07-20T12:57:58.313Z
Answers.UserDisplayName: Ramesh - ARTECH Consultancy
Body: <p>Is it possible to do a membership get api request with a "LIKE" operator <strong>with wildcards</strong> for membership_type_id?
  Trying this out, I get </p>
  
  <blockquote>
    <p>CiviCRM_API3_Exception: [2001: 'Something%' is not a valid option for
    field membership_type_id</p>
  </blockquote>
  
  <p>Which is fair enough enough but it means that LIKE isn't supported even though it's in the api explorer's operator dropdown.</p>
  
  <p>Thanks!</p>
  
Tags: <api>
Title: LIKE search in API for membership_type_id
ThreadText: # LIKE search in API for membership_type_id
  
  (Asked by: username_0 on 2016-07-19)
  
  Is it possible to do a membership get api request with a "LIKE" operator **with wildcards** for membership\_type\_id?
  Trying this out, I get
  
  > CiviCRM\_API3\_Exception: [2001: 'Something%' is not a valid option for
  > field membership\_type\_id
  
  Which is fair enough enough but it means that LIKE isn't supported even though it's in the api explorer's operator dropdown.
  
  Thanks!
  
  **Tags:** api
  
  
  ---
  
  ## 3 answers
  
  ### Answer by username_1 on 2016-07-19. Score: 1
  
  SQL doesn't support LIKE for integer fields. For something like membership type id I'm not even sure what it would mean unless you have 10 or more, and even then still not really meaningful.
  
  > **Comments:**
  > **username_0**: membership_type_id actually supports using the membership type name as well. Try the API explorer to see how it works.  
  > **username_1**: I saw there was another field membership_type. IDs are integers so it's kind of weird if an id query matches on a name/string. I'd expect to query on membership_type if I wanted string match.  
  > **username_0**: That's a fairly new development for convenience's sake, but yeah, it's a little confusing. It applies for other similar fields as well, eg option_group_id.  
  
  ---
  
  ### Answer by username_2 on 2018-07-17. Score: 0
  
  It seems it is working now in 2018 (have tried to find Relationships Type). Just put a search term (a word or part of something) in"LIKE" text area as **%YourSearchTerm%**
  
  
  ---
  
  ### Answer by username_3 on 2016-07-20. Score: 0
  
  Please use the following -
  
  For any integer you can use IN rather than Like
  
  ```
  $result = civicrm_api3('Membership', 'get', array(
    'sequential' => 1,
    'membership_type_id' => array('IN' => array("General", "Student")),
  ));
  
  ```
  
  If selecting string LIKE is used
  
  ```
  $result = civicrm_api3('Membership', 'get', array(
    'sequential' => 1,
    'source' => array('LIKE' => "payment"),
  ));
  
  ```
  
  I guess this helps!!!
  
  
  ---
  
  