I have 5 tables.
advertisingcompany Table id PK name placement Table id PK name advertiser Table id PK name location Table id PK name ads Table ad_id PK size price advertisingcompanyId FG placementId FG advertiserId FG locationId FG
I can't figure out how to show foreign key data. I can get for example "advertisingcompanyId" or "placementId" but the problem is to get instead of id the name of advertisingcompany which is in advertisingcompany table or placement name which is in placement table.
I tried with that query:
$query = "SELECT ad_id, size, price, ads.advertisingcompanyId, ads.placementId, ads.advertiserId, locationId
FROM ads
INNER JOIN advertisingcompany ON ads.advertisingcompanyId = advertisingcompany.id
WHERE ad_id = '$ad_id'";
Is that correct SQL query for data I wanted? If it is how can I add to that query I will get name for all foreign keys? How can I then show that data in php? Thanks