一百分相送,sql语法,决不食言

yyx770508 2003-09-15 01:56:49
我有个页面需要一下处理:
xzbmxx_info 部门表
info_policebase 人员信息表
原来方案:
<%
set ks_rst = server.CreateObject("adodb.recordset")
ks_sql = "select info_name,info_bh from xzbmxx_info order info_bh"
ks_rst.open ks_sql,conn,3,3
while not ks_rst.eof
'列出该部门人员列表
ry_sql = "select name,jobcode from info_policebase where unitid='"&ks_rst("info_bh")&"' order by jobcode"
set ry_rst=conn.execute(ry_sql)
while not ry_rst.eof
'输出部门名称
response.Write(ks_rst("info_name"))
'输出人员姓名
response.Write(ry_rst("name"))
'输出职务名称
set zw_rst = conn.execute("select mean from code_job where code='"&ry_rst("jobcode")&"'")
response.Write("  ("&zw_rst("mean")&")  ")
ry_rst.movenext
wend
ks_rst.movenext
wend
现在我想把两条sql合并成一条
select zhao.xzbmxx_info.info_name,zhao.info_policebase.name,zhao.info_policebase.jobcode
from zhao.info_policebase,zhao.xzbmxx_info
where zhao.info_policebase.unitid
in (select zhao.xzbmxx_info.info_bh from zhao.xzbmxx_info )
order by zhao.info_policebase.jobcode
出现死循环症状,请麻烦找出原因
asp+oracle环境
...全文
27 5 打赏 收藏 转发到动态 举报
写回复
用AI写文章
5 条回复
切换为时间正序
请发表友善的回复…
发表回复
liuzxit 2003-09-15
  • 打赏
  • 举报
回复
ORACLE支持inner join 嗎﹖

select xzbmxx_info.info_name,info_policebase.name,code_job.mean from xzbmxx_info,info_policebase,code_job where (xzbmxx_info.info_bh=info_policebase.unitid(+)) and (info_policebase.jobcode=code_job.code(+)) order xzbmxx_info.info_bh,info_policebase.jobcode

ORACLE不熟﹐也不知又否寫錯
阿云ivan 2003-09-15
  • 打赏
  • 举报
回复
Primer2002cn(宠辱不惊)的方法不失为一种好方法。
其实我想你之所以造成编程时那么难,最最主要的问题是出在:数据库没有设计好!
老兄,我建议你还是再好好设计一下你的数据库表结构吧。
对了,还有,你在命名的时候最好能规范化!
LONGFOR 2003-09-15
  • 打赏
  • 举报
回复
select zhao.xzbmxx_info.info_name,zhao.info_policebase.name,zhao.info_policebase.jobcode
from zhao.info_policebase,zhao.xzbmxx_info
where (兩 表關系表達式如:zhao.info_policebase.unitid=zhao.xzbmxx_info.info_bh; 條件:...)
order by zhao.info_policebase.jobcode
yzwxjun 2003-09-15
  • 打赏
  • 举报
回复
ORACLE不懂,帮你提贴子吧。
Primer2002cn 2003-09-15
  • 打赏
  • 举报
回复
select * from info_policebase inner join xzbmxx_info on info_policebase.unitid=xzbmxx_info.info_bh --两个相关联的字段
--员工------->部门

28,390

社区成员

发帖
与我相关
我的任务
社区描述
ASP即Active Server Pages,是Microsoft公司开发的服务器端脚本环境。
社区管理员
  • ASP
  • 无·法
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧