1. Get the order ids for all orders that have a shipping state of "New Jersey".
SELECT orders.ID
FROM `wp_posts` orders
INNER JOIN `wp_postmeta` meta ON meta.post_id = orders.ID
WHERE
orders.post_type = 'shop_order' AND
meta.meta_key = '_shipping_state' AND
meta.meta_value = 'NJ';