It depends on what you want to do. To do it once, this will work:
create table odx (order_id int, delivery_id int); create table dix
(delivery_id int, invoice_id int); create table iox (invoice_id int,
order_id int);
insert into odx values (1, 11), (2, 22), (3,33); insert into dix
values (22, 333), (22, 444), (33, 555); insert into iox values (333,
1), (444, 2), (555, 2);
create table odix (order_id int, delivery_id int, invoice_id int);
insert into odix (order_id, delivery_id, invoice_id) select
odx.order_id, odx.delivery_id, dix.invoice_id from odx
left join dix on dix.delivery_id = odx.delivery_id
left join iox on iox.order_id = odx.order_id;
But you have to make your own decisions about how to join the tables - because of the contents of the three tables, you can join them many ways with different results.
Also, you have to figure out what to do when any of the subsidiary tables changes - do you recreate the odix table from scratch or just add new or changed records.
You'll find that doing as much of this as possible in MySQL will be faster than in PHP - MySQL is very good at joining tables together and aggregating data in this way.
Finally, you probably want to think about why you are doing this - why put the data in another table. With MySQL, you can always assemble the data together to view them this way, so copying the data doesn't seem to make sense. It creates redundancy in your database, which can get confusing and difficult to manage.
Check out a few references on "normalization" to get some ideas.