Skip to main content
Add some new hints for solving the problem
Source Link

EDIT 2

I capture the query that Wordpress executes to MySql after converting the meta_query arguments:

SELECT SQL_CALC_FOUND_ROWS wpiw_posts.ID FROM wpiw_posts 
INNER JOIN wpiw_postmeta ON ( wpiw_posts.ID = wpiw_postmeta.post_id ) 
INNER JOIN wpiw_postmeta AS mt1 ON ( wpiw_posts.ID = mt1.post_id ) 
WHERE 1=1 AND 
( ( ( wpiw_postmeta.meta_key = 'pickup_address' AND wpiw_postmeta.meta_value LIKE '%Papamoa%' ) 
OR ( wpiw_postmeta.meta_key = 'pickup_address' AND wpiw_postmeta.meta_value LIKE '%BahÃa%' ) 
OR ( wpiw_postmeta.meta_key = 'pickup_address' AND wpiw_postmeta.meta_value LIKE '%de%' ) 
OR ( wpiw_postmeta.meta_key = 'pickup_address' AND wpiw_postmeta.meta_value LIKE '%Plenty%' ) ) 
AND ( mt1.meta_key = 'deliver_address' AND mt1.meta_value LIKE '%Auckland%' ) ) 
AND wpiw_posts.post_type = 'project' AND ((wpiw_posts.post_status = 'publish')) GROUP BY wpiw_posts.ID ORDER BY wpiw_posts.post_date DESC LIMIT 0, 10

I notice the weird chacarters 'BahÃa', but when i take this query and run it on MySql, it works! retrieves 1 row because one post have a pickup_address field with the word Papamoa and have a deliver_address field with the work Auckland.

EDIT 2

I capture the query that Wordpress executes to MySql after converting the meta_query arguments:

SELECT SQL_CALC_FOUND_ROWS wpiw_posts.ID FROM wpiw_posts 
INNER JOIN wpiw_postmeta ON ( wpiw_posts.ID = wpiw_postmeta.post_id ) 
INNER JOIN wpiw_postmeta AS mt1 ON ( wpiw_posts.ID = mt1.post_id ) 
WHERE 1=1 AND 
( ( ( wpiw_postmeta.meta_key = 'pickup_address' AND wpiw_postmeta.meta_value LIKE '%Papamoa%' ) 
OR ( wpiw_postmeta.meta_key = 'pickup_address' AND wpiw_postmeta.meta_value LIKE '%BahÃa%' ) 
OR ( wpiw_postmeta.meta_key = 'pickup_address' AND wpiw_postmeta.meta_value LIKE '%de%' ) 
OR ( wpiw_postmeta.meta_key = 'pickup_address' AND wpiw_postmeta.meta_value LIKE '%Plenty%' ) ) 
AND ( mt1.meta_key = 'deliver_address' AND mt1.meta_value LIKE '%Auckland%' ) ) 
AND wpiw_posts.post_type = 'project' AND ((wpiw_posts.post_status = 'publish')) GROUP BY wpiw_posts.ID ORDER BY wpiw_posts.post_date DESC LIMIT 0, 10

I notice the weird chacarters 'BahÃa', but when i take this query and run it on MySql, it works! retrieves 1 row because one post have a pickup_address field with the word Papamoa and have a deliver_address field with the work Auckland.

added 746 characters in body
Source Link

i have a little big problem with meta queries. I Designed a query to retrieve posts where any of these words exists in the custom field pickup_address. the field has this string in its meta value: 43 Longview Drive, Papamoa

EDIT

this is the meta query that Im using:

$args  = array(
'post_type'  => 'posts',
'meta_query' => array(
    'relation' => 'OR',
    array(
        'key'     => 'pickup_address', 
        'value'   => 'Papamoa', 
        'compare' => 'LIKE',
    ),
    array(
        'key'     => 'pickup_address', 
        'value'   => 'Bah�a',
        'compare' => 'LIKE',
    ),
    array(
        'key'     => 'pickup_address', 
        'value'   => 'de', 
        'compare' => 'LIKE',
    ),
    array(
        'key'     => 'pickup_address', 
        'value'   => 'Plenty',
        'compare' => 'LIKE', 
    ),
),

);

this is the code I generate from the meta queries:

SELECT SQL_CALC_FOUND_ROWS wpiw_posts.ID FROM wpiw_posts INNER JOIN
wpiw_postmeta ON ( wpiw_posts.ID = wpiw_postmeta.post_id ) WHERE 1=1
AND ( ( 
( wpiw_postmeta.meta_key = 'pickup_address' AND wpiw_postmeta.meta_value LIKE '%Papamoa%' ) OR
( wpiw_postmeta.meta_key = 'pickup_address' AND wpiw_postmeta.meta_value LIKE '%Bah�a%' ) OR 
( wpiw_postmeta.meta_key = 'pickup_address' AND wpiw_postmeta.meta_value LIKE '%de%' ) OR 
( wpiw_postmeta.meta_key = 'pickup_address' AND wpiw_postmeta.meta_value LIKE '%Plenty%' ) ) ) 
AND wpiw_posts.post_type = 'project' AND ((wpiw_posts.post_status = 'publish')) GROUP BY wpiw_posts.ID ORDER BY wpiw_posts.post_date DESC LIMIT 0, 10

I tried to replace the special character � but doesn't work either

Wordpress give me nothing on the Wp_Query($query_args) but if I run this in MySql it Works. Any help qould be appreciated

i have a little big problem with meta queries. I Designed a query to retrieve posts where any of these words exists in the custom field pickup_address. the field has this string in its meta value: 43 Longview Drive, Papamoa

this is the code I generate from the meta queries:

SELECT SQL_CALC_FOUND_ROWS wpiw_posts.ID FROM wpiw_posts INNER JOIN
wpiw_postmeta ON ( wpiw_posts.ID = wpiw_postmeta.post_id ) WHERE 1=1
AND ( ( 
( wpiw_postmeta.meta_key = 'pickup_address' AND wpiw_postmeta.meta_value LIKE '%Papamoa%' ) OR
( wpiw_postmeta.meta_key = 'pickup_address' AND wpiw_postmeta.meta_value LIKE '%Bah�a%' ) OR 
( wpiw_postmeta.meta_key = 'pickup_address' AND wpiw_postmeta.meta_value LIKE '%de%' ) OR 
( wpiw_postmeta.meta_key = 'pickup_address' AND wpiw_postmeta.meta_value LIKE '%Plenty%' ) ) ) 
AND wpiw_posts.post_type = 'project' AND ((wpiw_posts.post_status = 'publish')) GROUP BY wpiw_posts.ID ORDER BY wpiw_posts.post_date DESC LIMIT 0, 10

I tried to replace the special character � but doesn't work either

Wordpress give me nothing on the Wp_Query($query_args) but if I run this in MySql it Works. Any help qould be appreciated

i have a little big problem with meta queries. I Designed a query to retrieve posts where any of these words exists in the custom field pickup_address. the field has this string in its meta value: 43 Longview Drive, Papamoa

EDIT

this is the meta query that Im using:

$args  = array(
'post_type'  => 'posts',
'meta_query' => array(
    'relation' => 'OR',
    array(
        'key'     => 'pickup_address', 
        'value'   => 'Papamoa', 
        'compare' => 'LIKE',
    ),
    array(
        'key'     => 'pickup_address', 
        'value'   => 'Bah�a',
        'compare' => 'LIKE',
    ),
    array(
        'key'     => 'pickup_address', 
        'value'   => 'de', 
        'compare' => 'LIKE',
    ),
    array(
        'key'     => 'pickup_address', 
        'value'   => 'Plenty',
        'compare' => 'LIKE', 
    ),
),

);

this is the code I generate from the meta queries:

SELECT SQL_CALC_FOUND_ROWS wpiw_posts.ID FROM wpiw_posts INNER JOIN
wpiw_postmeta ON ( wpiw_posts.ID = wpiw_postmeta.post_id ) WHERE 1=1
AND ( ( 
( wpiw_postmeta.meta_key = 'pickup_address' AND wpiw_postmeta.meta_value LIKE '%Papamoa%' ) OR
( wpiw_postmeta.meta_key = 'pickup_address' AND wpiw_postmeta.meta_value LIKE '%Bah�a%' ) OR 
( wpiw_postmeta.meta_key = 'pickup_address' AND wpiw_postmeta.meta_value LIKE '%de%' ) OR 
( wpiw_postmeta.meta_key = 'pickup_address' AND wpiw_postmeta.meta_value LIKE '%Plenty%' ) ) ) 
AND wpiw_posts.post_type = 'project' AND ((wpiw_posts.post_status = 'publish')) GROUP BY wpiw_posts.ID ORDER BY wpiw_posts.post_date DESC LIMIT 0, 10

I tried to replace the special character � but doesn't work either

Wordpress give me nothing on the Wp_Query($query_args) but if I run this in MySql it Works. Any help qould be appreciated

Source Link

Meta Query doesn't works as espected

i have a little big problem with meta queries. I Designed a query to retrieve posts where any of these words exists in the custom field pickup_address. the field has this string in its meta value: 43 Longview Drive, Papamoa

this is the code I generate from the meta queries:

SELECT SQL_CALC_FOUND_ROWS wpiw_posts.ID FROM wpiw_posts INNER JOIN
wpiw_postmeta ON ( wpiw_posts.ID = wpiw_postmeta.post_id ) WHERE 1=1
AND ( ( 
( wpiw_postmeta.meta_key = 'pickup_address' AND wpiw_postmeta.meta_value LIKE '%Papamoa%' ) OR
( wpiw_postmeta.meta_key = 'pickup_address' AND wpiw_postmeta.meta_value LIKE '%Bah�a%' ) OR 
( wpiw_postmeta.meta_key = 'pickup_address' AND wpiw_postmeta.meta_value LIKE '%de%' ) OR 
( wpiw_postmeta.meta_key = 'pickup_address' AND wpiw_postmeta.meta_value LIKE '%Plenty%' ) ) ) 
AND wpiw_posts.post_type = 'project' AND ((wpiw_posts.post_status = 'publish')) GROUP BY wpiw_posts.ID ORDER BY wpiw_posts.post_date DESC LIMIT 0, 10

I tried to replace the special character � but doesn't work either

Wordpress give me nothing on the Wp_Query($query_args) but if I run this in MySql it Works. Any help qould be appreciated