Title: meta_value query
Last modified: August 22, 2016

---

# meta_value query

 *  [u22](https://wordpress.org/support/users/u22/)
 * (@u22)
 * [11 years, 3 months ago](https://wordpress.org/support/topic/meta_value-query/)
 * Hello everyone.
    I need a query to get the post_id from the postmeta table, but
   the meta_value is a serialized array, so I don’t know if it is posible, for example
   the meta_value is: `a:18:{s:9:"userID";s:6:"155184";s:9:"firstname";s:7:"John";
   s:8:"lastname";s:6:"Johnson";......` I need to select the post_id if there are
   users with ‘Johnson’ lastname, something like that. I’m using $wpdb->get_results
   and I have this query: `SELECT post_id FROM $wpdb->postmeta WHERE meta_key LIKE'%
   userData%' AND meta_value LIKE '%$lastname%'` It shows a result, but if the ‘
   lastname’ is in other part of the meta_value it will be selected too. I did use
   get_posts function with the same results.
 * Any help would be appreciated.

The topic ‘meta_value query’ is closed to new replies.

 * 0 replies
 * 1 participant
 * Last reply from: [u22](https://wordpress.org/support/users/u22/)
 * Last activity: [11 years, 3 months ago](https://wordpress.org/support/topic/meta_value-query/)
 * Status: not resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
