Kani R Kani R - 2 years ago 62
PHP Question

How to return two table values using join query

Here i am using JOIN query, it will working super, after merging two table value I return one table only, I don't know how return both tables values. From this code task tables value is returned, task_employee table value I can't return, I don't know what will do??

$dapartment = $_POST['department'];
$q = mysql_query("SELECT * FROM task_employee te, task t WHERE te.emp_designation='$dapartment' AND te.emp_id = t.t_assign_to");
$data = array();
while($r = mysql_fetch_assoc($q)){
$data[] = $r;
$count = sizeof($data);
if($count > 0){
echo json_encode($return);
echo json_encode($return);

Answer Source

The standard way of an inner join is:

SELECT * FROM task_employee te JOIN task t ON te.emp_id = t.t_assign_to WHERE te.emp_designation='$dapartment'
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download