select 表3.id,表3.ip,表1.gru_name,表2.loc_name from tbl_host_gru_loc 表3,tbl_location 表2,tbl_group 表1 
where  表3.gru_id =表1.id and 表3.loc_id =表2.id

解决方案 »

  1.   

    Dim sSql as stringsSql="Select tbl_host_gru_loc.ip,tbl_group.gru_name,tbl_location.loc_name from (tbl_host_gru_loc INNER JOIN tbl_group ON tbl_host_gru_loc.gru_id = tbl_group.id) INNER JOIN tbl_location ON tbl_host_gru_loc.locid = tbl_location.id"
      

  2.   

    select a.ip,b.gru_name,c.loc_name from 表3 a left join 表2 b on a.gru_id=b.id left join 表3 c on a.loc_id=c.id
      

  3.   

    呵呵,好久不用了,我的答案错了,  dongdonghan(宁静散人)  的对!!
      

  4.   

    Select 表3.id,表3.ip,表1.gru_name,表2.loc_name 
    from tbl_host_gru_loc 表3 INNER JOIN tbl_group  表1 ON 表3.gru_id =表1.id  INNER JOIN tbl_location 表2 ON 表3.loc_id =表2.id
      

  5.   

    dongdonghan(宁静散人) 谢谢你。
    虽然我想要的结果应该是left join,而不是你给出的inner join.但可能是我的提问说的不够清楚,无论如何,从你得答案,我才找到正确答案的,并且增加了对inner join ,leftjoin, right join 的认识,在此先谢过了。60分奉上