简体   繁体   中英

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){ 
    $return=array('status'=>'success','count'=>sizeof($data),'data'=>$data);
    echo json_encode($return);
}else{
    $return=array('status'=>'not-found','count'=>sizeof($data),'data'=>$data);
    echo json_encode($return);
}

内部联接的标准方式是:

SELECT * FROM task_employee te JOIN task t ON te.emp_id = t.t_assign_to WHERE te.emp_designation='$dapartment'

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM