Select distinct customers.* /* if(customervouchervalue.value = 0.00, customervouchervalue.value, publicationprices.price) as Price */ /* Distinct addresses. */ from rounddeliverypublications left outer join rounddeliveries on rounddeliveries.id = rounddeliverypublications.rounddeliveriesid left outer join publications on rounddeliverypublications.publicationid = publications.id left outer join publicationprices on publicationprices.id = rounddeliverypublications.publicationpricesid left outer join customervouchervalue on customervouchervalue.id = rounddeliverypublications.customervouchervalueid left outer join customers on rounddeliverypublications.customerid = customers.id left outer join addresses on customers.addressid = addresses.id Where customerid in (select id from customers Where shopid = 1252) and rounddeliveries.rounddate between '2011-12-11 00:00:00' and '2011-12-24 23:59:59' limit 0, 99999