I need some help with a mySQL query I'm using in my php script. Seems I may be a bit confused on the way my INNER JOIN's are working.
SELECT * FROM CART_CARD
INNER JOIN INVOICE ON CART_CARD.cartID = INVOICE.cart_invoice_id
INNER JOIN PURCHASE_CARD ON PURCHASE_CARD.invoiceID = INVOICE.ID
WHERE CART_CARD.cardEmail = '[email protected]'
AND PURCHASE_CARD.ID BETWEEN 26118 AND 26620
So there are 3 tables - CART_CARD, INVOICE, and PURCHASE_CARD.
PURCHASE_CARD has invoiceID, which matches up to INVOICE.ID. INVOICE has a field card cart_invoice_id which matches up to CART_CARD.cartID.
I'm getting results, but it looks like the results are doubling and tripling the rows that are in CART_CARD. Does my query look right?
Results I'm getting back from CART_CARD. Please keep in mind that ID is the unique primary field. I've omitted the rest of the fields because it is sensitive information:

SELECT DISTINCTunless you know exactly how and why duplicate rows are formed and that you want to have them. Normally, you don't.PURCHASE_CARDreturns more than one record which makes the records returned fromINVOICEandCART_CARDbecome duplicated.IDis a field taken fromPURCHASE_CARDthen you can see that there are multiple records inPURCHASE_CARDwhich point to the samecart-idlike I suggested earlier.group by, but both of you tried to "fix the result" instead of getting down to the source of the issue. Further, both your suggestions wouldn't work.PURCHASE_CARDby using a combination of join with the relevant table andLIMITthe resultset to 1.