0

I want to extract some data from my shop's database. The data I want is in four tables: ps_order_detail, ps_orders, ps_carrier and ps_customer. The main table is ps_order_detail. For each record of ps_order_detail I want to attach corresponding values from other tables based on id's: id_order, id_customer and id_carrier. The problem is that the base table (ps_order_detail) contains only id_order and the other id's are in ps_orders table. Do you know how can I solve this?

Isaac Bennetch
  • 11,830
  • 2
  • 32
  • 43
Wojtek Wencel
  • 2,257
  • 6
  • 31
  • 65

1 Answers1

1

Your question is unclear on the data layouts of the tables, but the query would look something like this:

select . . . 
from ps_order_detail od join
     ps_orders o
     using (id_order) join
     ps_customer c
     using (id_customer) join
     ps_carrier ca
     using (id_carrier)
Gordon Linoff
  • 1,242,037
  • 58
  • 646
  • 786