Note that there are some explanatory texts on larger screens.

plurals
  1. POMySql Query: Using Joins to get data not results good
    primarykey
    data
    text
    <p>I have two tables: EmployeeInfo Table (table 1) and ItemsInfo Table (table 2):</p> <p>Table 1:</p> <p><img src="https://i.stack.imgur.com/PSNCu.gif" alt="enter image description here"></p> <p>Table 2:</p> <p><img src="https://i.stack.imgur.com/S9g3v.gif" alt="enter image description here"></p> <p>In the UI screen , I have two DIV layers - the left div and the right div. The left div should load data of items not associated to employee and the right div should load the data associated to the employee.</p> <p>For example, on page load, for employee with empid=201, the data in both div should be populated like this: <img src="https://i.stack.imgur.com/FncaH.gif" alt="enter image description here"></p> <p>To achieve this, I want the mysql query output to be like this:</p> <p><img src="https://i.stack.imgur.com/1XuZJ.gif" alt="enter image description here"></p> <p>that is the returned json objects output to be like this :</p> <pre><code>[{"empid":"","itemid":"1","items":"Apple"},{"empid":"201","itemid":"2","items":"Banana"},{"empid":"","itemid":"3","items":"Baseball"},{"empid":"","itemid":"4","items":"Bikes"},{"empid":"201","itemid":"5","items":"Blue"}] </code></pre> <p>So that i can push the data to the appropriate div with getJson method. if empid=null, the data to be pushed in the left div else if the empid=201, the data to be pushed n the right div.</p> <p>I tried with Left Join but, since in table 1, all the field values are repeated more than once, i dont get the exact query output. </p> <p>Kindly help me how to achieve the above scenario.. Thanks in advance.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload