Forum Moderators: coopster

Message Too Old, No Replies

Writing data from 3 different tables to excel

everything works but...needs a little tweaking

         

mattyb515

5:54 pm on May 15, 2006 (gmt 0)

10+ Year Member



Ok so I'm the lucky one who gets to write a little snippet of code so that our new POS system gets data from our e-commerce site. I'm able to pull all of the relevant data from three different tables and I can get it to write it to a .csv file. However, if someone orders more than one item, it will write all of the customer info. again ie. customer name, address, phone, order number, etc. When all I really need written is the item number written in the item number column. I also just realized that I have run into an issue if there is more than one order in a day (which there always is). Should I break up the query into two different queries - one for the customer data and one for the items ordered?

alce

7:08 pm on May 15, 2006 (gmt 0)

10+ Year Member



Perhaps you could use SELECT DISTINCT

mattyb515

1:47 pm on May 16, 2006 (gmt 0)

10+ Year Member



I thought about that but was considering using a UNION statement. Now I'm not too familiar but was thinking about this:

SELECT blah FROM a LEFT JOIN ON a = c
UNION
SELECT blah FROM b LEFT JOIN a = b
WHERE
statements

Is this legal?