Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

You can use a variety of different comparison operators in meta queries, among which are 'LIKE', 'NOT LIKE', 'IN', and 'NOT IN'.

What is the difference in use between LIKE and IN?

Here's the relevant section of the WP Query Codex page:

meta_query (array) - Custom field parameters (3.1)

  • key (string) - Custom field key.
  • value (string|array) - Custom field value (Note: Array support is limited to a compare value of 'IN', 'NOT IN', 'BETWEEN', or 'NOT BETWEEN')
  • compare (string) - Operator to test. Possible values are '=', '!=', '>', '>=', '<', '<=', 'LIKE', 'NOT LIKE', 'IN', 'NOT IN', 'BETWEEN', 'NOT BETWEEN'. Default value is '='.
  • type (string) - Custom field type. Possible values are 'NUMERIC', 'BINARY', 'CHAR', 'DATE', 'DATETIME', 'DECIMAL', 'SIGNED', 'TIME', 'UNSIGNED'. Default value is 'CHAR'.

share|improve this question

1 Answer 1

up vote 1 down vote accepted

Meta queries are essentially wrapper for ease of setup, but end results is part of SQL query to run on MySQL database.

These operators are those of MySQL, see in documentation:

share|improve this answer
    
So IN would accept an array? –  supertrue Jan 18 '12 at 15:44
    
@supertrue from quick look at code it should and IN seems to be even automatically used instead of = in such case. –  Rarst Jan 18 '12 at 19:29

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.