I have three tables:
User (Table) - Email - Moblie - User_id Invoice_product (Table dbo.payware_factor_product ) - invoice_id - Product_id Invoice (Table dbo.payware_factor ) - User_id - Mobile - invoice_id
Each product has its own ID.
I want a query that, for example for
product_id 16, returns all customers who bought product 16 and the mobile number of customers only once.
But with the below query, if a customer has bought product 16 five times, the result shows his mobile number five times. How can I get it returned only once?
I wrote this query:
SELECT TBLA.mobile , TBLB.factor_id FROM dbo.payware_factor_product TBLB INNER JOIN dbo.payware_factor TBLA ON TBLB.factor_id = TBLA.factor_id WHERE TBLB.product_id = 16 AND TBLA.mobile = (SELECT mobile )