title: How to fetch a column from another table according to specific condition?
body: <p>I'm making a webform of a hospital in VS-2012 using three-tier architecture. And I'm using MS-SQL Server 2014. Also, I'm new to the coding so it will be really helpful if the answer is given without using any jargons. Thanks.</p>
  
  <p>1.contains picture of the form . [1]: <a href="https://i.stack.imgur.com/tOhGh.png" rel="nofollow noreferrer">https://i.stack.imgur.com/tOhGh.png</a>.</p>
  
  <p>[2]: <a href="https://i.stack.imgur.com/DrB4e.png" rel="nofollow noreferrer">https://i.stack.imgur.com/DrB4e.png</a> and this is the coding behind the last two columns in the form, i.e, preferred time and specialty. As you see the values for the preferred time is day and night only and for the specialty, there are different departments involved. </p>
  
  <ol start="3">
  <li>Now, I want to CREATE A STORED PROCEDURE which will insert the data into the appointment table given here [3]: <a href="https://i.stack.imgur.com/wtLqA.png" rel="nofollow noreferrer">https://i.stack.imgur.com/wtLqA.png</a> according to the shift and specialty. Also, it is important to fetch the doctor_id from the doctor table [4] <a href="https://i.stack.imgur.com/UKV5W.png" rel="nofollow noreferrer">https://i.stack.imgur.com/UKV5W.png</a> according to the shift and specialty. 
  Is there any way I can do it? </li>
  </ol>
  
  <p>Thank you.</p>