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.