I am fighting with a syntax error and I can't really find the problem.
this is my query
SELECT * FROM wp_postmeta PM1
WHERE PM1.meta_key = '_pronamic_google_maps_latitude'
AND PM1.post_id = '$id'
JOIN wp_postmenta PM2
WHERE PM2.post_id = PM1.post_id
AND PM2.meta_key = '_pronamic_google_maps_longitude'
and getting this error:
You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'JOIN wp_postmeta PM2' at line 3
could please someone can give me a hint what i'm missing?
First have to come the join then the rest of the query. So something like
SELECT * FROM wp_postmeta PM1
JOIN wp_postmenta PM2 on PM1.post_id = PM2.post_id
WHERE PM1.meta_key = '_pronamic_google_maps_latitude'
AND PM1.post_id = '$id'
AND PM2.meta_key = '_pronamic_google_maps_longitude'
You've two where clauses and the join order is wrong:
select ...
from ...
join ... on ...
where ... and ...
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With