I’m trying to Query some lattitude and logitude and then I get some long numbers and apperently the Query dont like that.
Let says I have these in the database
Meta-key: lat
Meta-value: 54.3415000
Meta-key: lng
Meta-value: 10.1254100
and do a query like this:
$args['meta_query'] =
array(
'relation' => 'AND',
array(
'key' => 'lat',
'value' => array( '53.82659686199116', '54.946076335668714' ),
'type' => 'NUMERIC',
'compare' => 'BETWEEN',
),
array(
'key' => 'lng',
'value' => array( '8.429260683593725', '11.889954042968725' ),
'type' => 'NUMERIC',
'compare' => 'BETWEEN',
)
);
Then it works, BUT, when it looks like this:
$args['meta_query'] =
array(
'relation' => 'AND',
array(
'key' => 'lat',
'value' => array( '54.10933293482647', '54.66906633195788' ),
'type' => 'NUMERIC',
'compare' => 'BETWEEN',
),
array(
'key' => 'lng',
'value' => array( '9.294434023437475', '11.024780703124975' ),
'type' => 'NUMERIC',
'compare' => 'BETWEEN',
)
);
Then it does not work, even it is still between the 2 numbers.
Anyone have a clue what is going on here ? Must be some MYSQL stuff.
EDIT:
Here is what a mysql request looks like:
SELECT SQL_CALC_FOUND_ROWS wp_posts.ID FROM wp_posts INNER JOIN wp_postmeta ON
(wp_posts.ID = wp_postmeta.post_id)INNER JOIN wp_postmeta AS mt1 ON
(wp_posts.ID = mt1.post_id) WHERE 1=1 AND wp_posts.post_type="branchenbuch"
AND (wp_posts.post_status="publish" OR wp_posts.post_status="future"
OR wp_posts.post_status="draft" OR wp_posts.post_status="pending"
OR wp_posts.post_status="private") AND ( (wp_postmeta.meta_key = 'lat'
AND CAST(wp_postmeta.meta_value AS SIGNED) BETWEEN '54.1833340338'
AND '54.4636527622')AND (mt1.meta_key = 'lng' AND CAST(mt1.meta_value AS SIGNED)
BETWEEN '9.76272625977' AND '10.6278995996') ) GROUP BY wp_posts.ID
ORDER BY wp_posts.post_date DESC LIMIT 0, 10