Hi, I am using Simplemaps version 2.4.4.1, WordPress 3.3.1.
I added 2 locations and assigned them each to their own category. If I select 1 it brings results on the map, but if I select both it doesn't come up with anything.
I narrowed down the problem to the Inner Join SQL statement, in xml-search.php, line 81-85:
INNER JOIN
$wpdb->term_taxonomy AS tax_$i ON
term_rel_$i.term_taxonomy_id = tax_$i.term_taxonomy_id
AND tax_$i.taxonomy = '$taxonomy'
AND tax_$i.term_id $search_value
which generates this query when I select both categories:
SELECT
lat_tbl.meta_value AS lat,
lng_tbl.meta_value AS lng,
( 3959 * ACOS( COS( RADIANS('48.1127929') ) * COS( RADIANS( lat_tbl.meta_value ) ) * COS( RADIANS( lng_tbl.meta_value ) - RADIANS('11.568187200000011') ) + SIN( RADIANS('48.1127929') ) * SIN( RADIANS( lat_tbl.meta_value ) ) ) ) AS distance,
posts.ID,
posts.post_content,
posts.post_title
FROM
wp_posts AS posts
INNER JOIN
wp_postmeta lat_tbl ON lat_tbl.post_id = posts.ID AND lat_tbl.meta_key = 'location_lat'
INNER JOIN
wp_postmeta lng_tbl ON lng_tbl.post_id = posts.ID AND lng_tbl.meta_key = 'location_lng'
INNER JOIN
wp_term_relationships AS term_rel_1 ON posts.ID = term_rel_1.object_id
INNER JOIN
wp_term_taxonomy AS tax_1 ON
term_rel_1.term_taxonomy_id = tax_1.term_taxonomy_id
AND tax_1.taxonomy = 'sm-category'
AND tax_1.term_id = 16
INNER JOIN
wp_term_relationships AS term_rel_2 ON posts.ID = term_rel_2.object_id
INNER JOIN
wp_term_taxonomy AS tax_2 ON
term_rel_2.term_taxonomy_id = tax_2.term_taxonomy_id
AND tax_2.taxonomy = 'sm-category'
AND tax_2.term_id = 17
WHERE
posts.post_type = 'sm-location'
AND posts.post_status = 'publish'
GROUP BY
posts.ID
HAVING distance < 31
ORDER BY
distance, posts.post_name ASC
LIMIT 20
I did some QA with the database, but I am not sure where exactly the problem lies. If I leave the inner joins out, the results are working just fine (but of course there's then trouble when I only select one category).
Any hints?
Thanks, flymke