Combining results from two pairs of tables

Combining results from two pairs of tables

am 08.05.2006 05:03:42 von m.k.ball

Hi - I have some tables designed to keep track of order. The main table
contains a session id, address and date. Linked to this I have a table
of items that make up each order. I'm concerned that over the course of
a few weeks performance will slow down as the tables fill up, so I
though I would make duplicates of each table and have any orders over a
month old moved (along with the corresponding items) to the duplicate
tables. I would appreciate any advice from anyone who has had a similar
problem on whether I'm going about this the right way, and secondly, is
there a way to write a query that will recombine the separated entries
into a single date-ordered list?

orders: session_id, name, address, date (PRIMARY: session_id)

items: session_id, item_no, item_name, price, date (PRIMARY:
session_id+item_no)

old_orders: session_id, name, address, date (PRIMARY: session_id)

old_items: session_id, item_no, item_name, price, date (PRIMARY:
session_id+item_no)

Michael

Re: Combining results from two pairs of tables

am 10.05.2006 09:08:41 von planetthoughtful

m.k.ball@btinternet.com wrote:
> Hi - I have some tables designed to keep track of order. The main table
> contains a session id, address and date. Linked to this I have a table
> of items that make up each order. I'm concerned that over the course of
> a few weeks performance will slow down as the tables fill up, so I
> though I would make duplicates of each table and have any orders over a
> month old moved (along with the corresponding items) to the duplicate
> tables. I would appreciate any advice from anyone who has had a similar
> problem on whether I'm going about this the right way, and secondly, is
> there a way to write a query that will recombine the separated entries
> into a single date-ordered list?

Check out the use of UNION or UNION ALL etc to join query results
together:

http://dev.mysql.com/doc/refman/5.0/en/union.html

Much warmth,

planetthoughtful
---
"lost in thought"
http://www.planetthoughtful.org1

Re: Combining results from two pairs of tables

am 10.05.2006 16:16:44 von m.k.ball

Bless you for that, planetthoughtful :-)
that's just what I need.
Michael