The issue has to do with the LOGOS table that has 3 columns - logo_id, business_location_content_
id_fk and logo_timestamp.
There are multiple results when searching on LOGOS.business_location_co
k, each record returning a unique LOGOS.logo_timestamp.
In the query above, I need to return the highest LOGOS.logo_timestamp value (most recent unix timestamp) for the LOGOS.business_location_co
k being searched on.
Alternatively, if the query returned ALL of the LOGOS.logo_timestamp values for the LOGOS.business_location_co
k being searched on, (there will not be many), I could sort for the highest value downstream using PHP... but I would prefer not to :-)
Currently, the above query returns just one record, and it is the lowest LOGOS.logo_timestamp value (which also corresponds with the lowest auto incrementing logo_id PK)
Help with the query would be appreciated.
$q_Result_Number = "SELECT
, business_location.business_location_vpid AS bID
, business_location.business_location_package_type AS pack_type
, LOGOS.logo_timestamp as logo_name
, keyphrases.keyphrase_type AS key_type ".
"FROM search ".
"INNER JOIN business_location ON search.business_location_vpid_fk = business_location.business_location_vpid ".
"INNER JOIN keyphrases ON business_location.business_location_content_id = keyphrases.business_location_content_id_fk AND keyphrases.keyphrase_words IN ('" . $myQuery . "') ".
"INNER JOIN LOGOS ON business_location.business_location_content_id = LOGOS.business_location_content_id_fk ".
"WHERE search.search_show = 1 ".
"AND keyphrases.keyphrase_type IN ('1', '2', '3') ".
"AND business_location.business_location_package_type BETWEEN 2 AND 5 ".
"GROUP BY business_location.business_location_content_id ".
"ORDER BY pack_type DESC";