I'm trying to get this to display but every time I try it, it says "empty set" instead of showing me what I need. Here is an image of the database schema
Here is what is being asked of me:
Construct the SQL statement to find all of the messages that message.sender_id = 1 sent. Note: You must use the WHERE clause to set the conditions for this query. Display the following columns: - Sender's first name - Sender's last name - Receiver's first name - Receiver's last name - Message ID - Message - Message Timestamp
And this is the MYSQL code that I came up with, but like I said, it only returns and empty set.
SELECT
person.first_name AS "Sender's first name",
person.last_name AS "Sender's last name",
person.first_name AS "Receiver's first name",
person.last_name AS "Receiver's last name",
message.message_id AS "Message ID",
message.message AS "Message",
message.send_datetime AS "Message Timestamp"
FROM message
JOIN person ON message.sender_id = person.person_id AND message.receiver_id = person.person_id
WHERE message.sender_id = 1;
I can't figure out how to get the first and last name for the person table to display based on the sender and receiver id in the message table.
Any help would be great! Thank you!
personwhereperson_id = 1