I am trying to get data from two tables names as
1.TICKET_MESSAGE_TABLE
2.TICKET_ATTACHMENT_TABLE
Query is below
$sql='SELECT msg.*, count(attach_id) as attachments
FROM '.TICKET_MESSAGE_TABLE.' msg '.
' LEFT JOIN '.TICKET_ATTACHMENT_TABLE.' attach ON msg.ticket_id=attach.ticket_id
AND msg.msg_id=attach.ref_id '.
' WHERE msg.ticket_id='.db_input($this->getId()).
' GROUP BY msg.msg_id
ORDER BY msg.created desc';
$msgres=db_query($sql);
return $msgres;
The problem is the last record from the table TICKET_MESSAGE_TABLE is not fetching until we not insert the new record in this table. Can any one have idea of this problem. Please.