It seems I'm having a problem implementing UNION:
$query_timebased = ("SELECT lat, lng, username, type FROM ".$ss_mm_prefix."mapdata a INNER JOIN ".$phpbb_prefix."users b USING(user_id) WHERE type ='member' AND marker_active = '1' ORDER BY marker_placed DESC LIMIT 5
UNION
SELECT id, name, type FROM ".$ss_poi_prefix."data WHERE type ='event' AND active = '1' ORDER BY created DESC LIMIT 5
UNION
SELECT id, name, type FROM ".$ss_poi_prefix."data WHERE type ='poi' AND active = '1' ORDER BY created DESC LIMIT 5");
I get "Incorrect usage of UNION and ORDER BY". UNION ALL results in the same error.
If I bracket each separate query:
$query_timebased = ("(SELECT lat, lng, username, type FROM ".$ss_mm_prefix."mapdata a INNER JOIN ".$phpbb_prefix."users b USING(user_id) WHERE type ='member' AND marker_active = '1' ORDER BY marker_placed DESC LIMIT 5)
UNION ALL
(SELECT id, name, type FROM ".$ss_poi_prefix."data WHERE type ='event' AND active = '1' ORDER BY created DESC LIMIT 5)
UNION ALL
(SELECT id, name, type FROM ".$ss_poi_prefix."data WHERE type ='poi' AND active = '1' ORDER BY created DESC LIMIT 5)");
Then I get "The used SELECT statements have a different number of columns".
Could someone help me figure out what I'm screwing up?