Hi all.
This is my sql query in a "photo of the day" by postcards sended since beginning of the day
$timestamp = strtotime(date("d-m-Y"));
$sql = "SELECT c.image_id, COUNT(c.image_id ) AS NumOccurrences, c.postcard_date, i.image_id, i.cat_id, i.user_id, i.image_name, i.image_description, i.image_keywords, i.image_date, i.image_active, i.image_media_file, i.image_thumb_file, i.image_download_url, i.image_allow_comments, i.image_comments, i.image_downloads, i.image_votes, i.image_rating, i.image_hits, d.cat_name
FROM (".POSTCARDS_TABLE." AS c)
LEFT JOIN (".IMAGES_TABLE." AS i, ".CATEGORIES_TABLE." d) ON ( c.image_id = i.image_id )
WHERE (c.postcard_date > ".$timestamp.")
GROUP BY c.image_id
HAVING (COUNT( c.image_id ) >1)
ORDER BY NumOccurrences DESC
LIMIT 1";