title: Join two table in the single query. Need query to execute my php code
body: <p>I have 2 table called <strong>result</strong> and <strong>subject</strong> </p>
  
  <p><img src="https://i.stack.imgur.com/xcl83.png" alt="result table"></p>
  
  <p><img src="https://i.stack.imgur.com/atzlb.png" alt="subject table"></p>
  
  <p>and i want to show data like this</p>
  
  <p><img src="https://i.stack.imgur.com/NdIss.png" alt="click here"></p>
  
  <p>I have the following code :</p>
  
  <pre><code>$result_hallticket= "13d01a0589";
  $subject_department= "Civil";
  </code></pre>
  
  <p>if i search with any hallticket and department, the subject name and max marks shows every time with  the select statement </p>
  
  <pre><code>select * 
  from subject 
  where subject_department='$subject_department' 
    AND subject_semester="1-1";
  </code></pre>
  
  <p>So i want all subject name should come and internal and external marks come from result database with the matching of hallticket and semester. If the matching found then show the number </p>
  
  <pre><code>subject_name=result_subject
  </code></pre>
  
  <p>if not found any result then show only 0 marks in both internal and external marks.</p>
  
  <p>i need a single query to show these all.</p>
  
  <p>What i actually need:
  I need a table with 4 column (Subject Name, Max Marks, Internal Marks, External Marks)</p>
  
  <p>The Subject Name and Max Marks come from <strong>subject</strong> table and internal marks and external marks will come from <strong>result</strong> table.</p>
  
  <p>The Subject Name and Max Marks will depends upon department and semester. And the Internal marks and external marks will depends upon hallticket, semester and subject.</p>