I’m trying to load activities from a database with a specific location. I try to do that with this query:
public function selectAllActivities(){
$sql = "SELECT * FROM `activities` INNER JOIN `locations` on `activities`.`location_id` = `locations.id`";
$stmt = $this->pdo->prepare($sql);
$stmt->execute();
return $stmt->fetchAll(PDO::FETCH_ASSOC);
}
However when I load the website, I get this error:
Column not found: 1054 Unknown column 'locations.id' in 'on clause
2
Answers
Have you tried
Inner joins should read like
You can read more at this URL
That’s a typo, but I can’t explain it in comment because of the backticks.
This :
Is meant to be