WooCommerce – Query for ordered products

Fixed query

select 
        p.ID as order_id,
        p.post_date,
        i.order_item_name,
        max( CASE WHEN im.meta_key = '_product_id' and i.order_item_id = im.order_item_id THEN im.meta_value END ) as Prod_ID
    from 
        wp_posts as p,
        wp_postmeta as pm,
        wp_woocommerce_order_items as i,
        wp_woocommerce_order_itemmeta as im
    where 
        p.post_type="shop_order"
        and p.ID = pm.post_id
        and p.ID = i.order_id
        and p.post_date BETWEEN '2016-01-14 00:00:00' AND '2016-01-14 23:59:59'
        and p.post_status="wc-processing"

Explanation: Post ID has no direct relation to the order item meta