return all addresses of a single offer in php

Wednesday, November 4, 2015

I have an offers table which has an offer from a client. I also have an addresses table with a list of addresses. Finally a third table which stores the offer id and the address id to marry the two together. One offer can have many address's and each address can be used more than once for different offers.



Im trying to run a single query that not only returns me the offer but all the addresses that are linked to it. My query works and currently returns me an address but its only returning one address not all of them. Here is my query



 SELECT offer.*, clientAddress.*

FROM `offer`

LEFT JOIN offerAddress ON offerAddress.idoffer = offer.idoffer
INNER JOIN clientAddress ON clientAddress.idclientAddress = offerAddress.idclientAddress
WHERE
offer.idoffer=%s


If I then try to access the client Address details I only get the first address it found not all of them. In this case there should be 2 addresses returned.

0 comments:

Post a Comment