0

I have calendar table with columns(id,agent_id,date,location) and agent table with columns(id,name,phone_number,email). I need to create a view of calendar table with additional column(agent_email),where agent_email is from agent table email column as same as agent_id in calendar table is id from agent table.

enter image description here

I have tried as in above screenshot,but instead of agent_email in table column ,I have ?column?.

7
  • Can you post the actual SQL statements to create your tables? Commented Dec 8, 2022 at 10:24
  • @SebDieBln I have already created those both tables(calendar,agent) Commented Dec 8, 2022 at 10:28
  • Well, but I haven't. And I could only help you once I have :-) Commented Dec 8, 2022 at 10:30
  • 3
    You are looking for a join Commented Dec 8, 2022 at 10:31
  • 3
    Please do not post code as images. See here for more details why: meta.stackoverflow.com/questions/285551 Commented Dec 8, 2022 at 11:11

1 Answer 1

1
select calendar_events.*, agents.email
from calendar_events
left outer join agents on calendar_events.agent_id=agents.id;

This gives my expected answer ,

columns :

id | agent_id | date | location | agent_email

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.