$sql = 'SELECT a.status,a.taskID,a.tel,b.status FROM a left join b on (a.taskID=b.taskID and a.tel=b.tel)';
$query = mysql_query($sql);
while ($row = mysql_fetch_array($query)){
if ($row['3']>0){
$list[$row['1']][$row['2']]=$row['3'];
}else{
$list[$row['1']][$row['2']]=$row['0'];
}
}这样应该满足你的要求

解决方案 »

  1.   

    select * from b
    union all
    select * from a where not exists(select 1 from b where a.taskid=b.taskid and a.tel=b.tel)
      

  2.   

    select case when sb is not null then sb else sa end status,id 
    from 
    (select b.status sb,a.status sa,a.id from a left join b on a.taskid=b.taskid and a.tel=b.tel) c;
      

  3.   

    SELECT * FROM TableA WHERE (taskid, tel) not in(SELECT taskid, tel FROM TableB)
    UNION
    SELECT * FROM TableB