MySQL Forums
Forum List  »  Newbie

Duplicate row using join
Posted by: Eric Chaland
Date: January 20, 2009 09:23PM

Hello,
I getting duplicate transaction rows when I use JOIN even though I used DISTINCT.

Table Transaction - columns: transaction_id, customer_id ...
Table Transaction_detail - columns: transaction_detail_id, transaction_id, product_name ....
Table Customer - columns: customer_id, address_id ...
Table Address - columns: address_id, customer_id, transaction_id ...

The query is as follow:

SELECT DISTINCT transaction.transaction_id,
transaction.transaction_id,
transaction.transaction_date,
transaction.customer_id,
transaction.purchase_order,
transaction_detail.product_name,
customer.email,
customer.ip_address,
address.phone
FROM transaction LEFT JOIN customer ON transaction.customer_id = customer.customer_id
LEFT JOIN address ON customer.address_id = address.address_id
LEFT JOIN transaction_detail ON transaction.transaction_id = transaction_detail.transaction_id
WHERE transaction.transaction_date < '2009-01-21'

What am I doing wrong? I get duplicate transaction rows.
Thanks in advance for your help

Options: ReplyQuote


Subject
Written By
Posted
Duplicate row using join
January 20, 2009 09:23PM
January 20, 2009 09:39PM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.