Skip to main content
3 of 4
added 1 character in body
HelgeB
  • 4.5k
  • 2
  • 11
  • 27

Information about the order you will get from the table sales_flat_order while information at order line level you find in sales_flat_order_item. To get informations at order level and at order line item you have to join both tables.

select o.*, oi.* from sales_flat_order o
join sales_flat_order_item oi on o.entity_id = oi.order_id where oi.parent_item_id is null and ....

With this statement you will get all information from both tables please adapt it however you need it. The condition parent_item_id is null is to avoid double listing configurale products, which are stored twice (one line for parent and one for the child). Please note: you will get for each order as many rows as there are order lines.

If you need one row per order you have to add group by oi.order_id to your statement and sum before the numeric order_item columns you request in the statement.

HelgeB
  • 4.5k
  • 2
  • 11
  • 27