我试图显示添加的图片的最后“日期”, 与特定人有关。
如果我在下面输入一个额外的元素
ORDER BY:,timestamp
DESC结果没有变化。同
我得到第一张照片的日期。
有些人有一个图像,有些人有五个或更多。 数据库中约有1500人。
正确返回所有其他数据/图像。
我在网上找不到任何关于我的问题的参考, 更多的概括。
由于
输出结果为: -
Person's - Person - Nos Of - Last Picture
Picture Name Pictures "Date"
-------- ------ -------- ------------
image Tony 5 26th June 2012
image Beth 1 6th January 2011
image John 2 5th May 2012
msql_query是: -
<?php
function person($person_id) {
$persons = array();
$persons_query = mysql_query("
SELECT `persons`.`person_id`, `persons`.`person_name`,
LEFT(`persons`.`person_description`, 50) as `person_description`,
`person_images`.`timestamp`, `person_images`.`image_person_id`,
`person_images`.`person_name`, `person_images`.`ext`,
COUNT(`person_images`.`image_person_id`) as `image_count`
FROM `persons`
LEFT JOIN `person_images`
ON `persons`.`person_id` = `person_images`.`person_id`
LEFT JOIN `person_images`
ON `persons`.`person_id` = `person_images`.`person_id`
WHERE `persons`.`member_id` = ".$_SESSION['member_id]
GROUP BY `persons`.`person_id`
ORDER BY `persons`.`person_name`,
");
While ($persons_row = mysql_fetch_assoc($persons_query)) {
$persons[] = array(
'person_id' => $persons_row['person_id'],
'person_name' => $persons_row['person_name'],
'person_description' => $persons_row['person_description'],
'timestamp' => $persons_row['timestamp'],
'image_person_id' => $persons_row['image_person_id'],
'ext' => $persons_row['ext'],
'count' => $persons_row['image_count']
);
}
return $persons;
}
?>
答案 0 :(得分:2)
我认为您的问题与订购无关,因为您只对最新图片的日期感兴趣。那你怎么试试呢:
MAX(timestamp) GROUP BY person_id