我有这行代码:
$query = mysqli_query($connection, "SELECT `id`, `image`, `link`, `order` FROM `galleryImages` INNER JOIN `galleries` ON `galleryImages`.`galleryId` = `galleries`.`id`");
它返回此错误:
Warning: mysqli_fetch_assoc() expects parameter 1 to be mysqli_result
完整代码:
$query = mysqli_query($connection, "SELECT `id`, `image`, `link`, `order` FROM `galleryImages` INNER JOIN `galleries` ON `galleryImages`.`galleryId` = `galleries`.`id`");
$results = array();
while($row = mysqli_fetch_assoc($query)){
$results[] = $row;
}
return $results;
答案 0 :(得分:1)
尝试:
"SELECT `id`, `image`, `link`, `order`
FROM `galleryImages` `g`
INNER JOIN `galleries` `g2` ON `g`.`galleryId` = `g2`.`id`"
答案 1 :(得分:1)
这应该有用..
SELECT
`galleries`.`id`,
`galleries`.`image`,
`galleries`.`link`,
`galleries`.`order`
FROM
`galleryImages`
INNER JOIN `galleries`
ON `galleryImages`.`galleryId` = `galleries`.`id`