php - Distinguishing ID's

187

This is my query:

$tsql = "SELECT *
FROM 
    dbo.messages m INNER JOIN
    dbo.contacts c
    ON m.contactID = c.ID
WHERE 
    assigned='{$_COOKIE['member_name']}'
ORDER BY
    m.status DESC, m.ID DESC";

This returns the contact ID but not the message ID. How do I get it to show:

<?php echo $row['ID'] ?>

But with the message ID and not the contact ID in an HTML form?

2

Answer

Solution:

you can access id of c table using cid, and id of m table as mid

like $row['cid'] and $row['mid']

    $tsql = "SELECT m.*, c.*, c.id as cid, m.id as mid
    FROM 
        dbo.messages m INNER JOIN
        dbo.contacts c
        ON m.contactID = c.ID
    WHERE 
        assigned='{$_COOKIE['member_name']}'
    ORDER BY
        m.status DESC, m.ID DESC";

People are also looking for solutions to the problem: How to send message using Gmail API with PHP YII2 Google API Client?

Source

Didn't find the answer?

Our community is visited by hundreds of web development professionals every day. Ask your question and get a quick answer for free.

Ask a Question

Write quick answer

Do you know the answer to this question? Write a quick response to it. With your help, we will make our community stronger.

Similar questions

Find the answer in similar questions on our website.