我有一个连接表(details),连接两个数据表,sql语句是:SELECT sjxx.*, baoxiu.*
FROM baoxiu INNER JOIN sjxx ON baoxiu.baoxiu_user = sjxx.username;我的程序中的代码是:
Dim baoxiu_id,rs
baoxiu_id=cint(request("baoxiu_id")) set rs=server.createobject("adodb.recordset")
 sql="select *  from details where baoxiu_id=" & baoxiu_id
 rs.open sql,conn,3,2
 if rs.eof and rs.bof then
rs.close
set rs=nothing
'Response.Write "<script>alert('"& baoxiu_id &"');window.location.href='index.asp';</script>"
Response.Write "<script>alert('该用户未登记计算机基本信息,请补充登记');window.location.href='index.asp';</script>"
Response.end end if如果有匹配的数据,就能显示全部的数据;如果没有匹配的数据,就有了上面的语句,程序中止了,就不能继续,我现在想在没有匹配数据的情况下,也能够显示baoxiu表中的所有数据,而sjxx表中的数据就不显示,或者赋为空值。不知道怎么实现,请大家帮帮忙,明天就要交作业了,谢谢!!!

解决方案 »

  1.   

    用left join 或 right join
      

  2.   

    Dim baoxiu_id,rs 
    baoxiu_id=cint(request("baoxiu_id")) set rs=server.createobject("adodb.recordset") 
    sql="select *  from details where baoxiu_id=" & baoxiu_id 
    rs.open sql,conn,3,2 
    if rs.eof and rs.bof then 
    rs.close response.write "第一次查询没有记过"
    dim xsql,
    xsql="select * from baoxiu"
    rs.open xsql,conn,1,1       'conn为打开数据库对象
    if rs.bof and rs.eof then
        response.write "表BAOXIU没有数据"
    else
        do while not rs.eof
        '显示数据操作....
        rs.movenext
        loop
    end if
    rs.close
    set rs=nothing
    Response.end end if 
      

  3.   

    感谢free_wind22(方法行的通),shenzhenNBA(办法调试不通过).  问题已解决。