日期:2014-05-17  浏览次数:20824 次

高分求解联合查询语句!
有三张表:
te_vehicletarget  
tr_tmn_vehicle  
te_terminal 


我要查询的是
te_vehicletarget表下的
te_vehicletarget.reg_date,te_vehicletarget.open_date,te_vehicletarget.close_date;
tr_tmn_vehicle表下的
tr_tmn_vehicle.bindtime
where条件 tr_tmn_vehicle.SU_MDN = ' ';


关联为:te_vehicletarget.ID = tr_tmn_vehicle.VHC_ID;
  te_terminal.ID = tr_tmn_vehicle.TMn_ID
 但是我想了一下午也没有想明白!



------解决方案--------------------
select 
te_vehicletarget.reg_date,te_vehicletarget.open_date,te_vehicletarget.close_date
from 
te_vehicletarget,
tr_tmn_vehicle,
te_terminal
where te_vehicletarget.ID = tr_tmn_vehicle.VHC_ID;
 and te_terminal.ID = tr_tmn_vehicle.TMn_ID
 and tr_tmn_vehicle.SU_MDN = ' '

------解决方案--------------------
你表结构也没有。。。各个字段也没描述,不知下面的是不是你要的
SQL code
SELECT te_vehicletarget.reg_date,te_vehicletarget.open_date,te_vehicletarget.close_date, tr_tmn_vehicle.bindtime
FROM ttr_tmn_vehicle,te_terminal,e_vehicletarget  
where tr_tmn_vehicle.SU_MDN = ' ' AND te_vehicletarget.ID = tr_tmn_vehicle.VHC_ID AND te_terminal.ID = tr_tmn_vehicle.TMn_ID

------解决方案--------------------
te_vehicletarget m条
tr_tmn_vehicle n条
te_terminal p条
做连接m*n*p条,
where条件,就是将这m*n*p条数据中的每条数据进行过滤,符合的留下,不符合的过滤……

------解决方案--------------------
select a.te_vehicletarget.reg_date,a.te_vehicletarget.open_date,a.te_vehicletarget.close_date,b.tr_tmn_vehicle.bindtime 
from 
te_vehicletarget a,tr_tmn_vehicle b,te_terminal c
where 
a.te_vehicletarget.ID = b.tr_tmn_vehicle.VHC_ID 
and
a.te_terminal.ID = b.tr_tmn_vehicle.TMn_ID 
and
b.tr_tmn_vehicle.SU_MDN = ''