检索是否重复的问题。

sunsbn2 2009-09-21 04:24:54
分类表class
信息表info
分类ID和信息表的class_id相关联!
每条信息的名称在相同的分类里不能重复,但不同的分类里面是可以有重复的名称的。 这个怎么弄。
...全文
100 12 打赏 收藏 转发到动态 举报
写回复
用AI写文章
12 条回复
切换为时间正序
请发表友善的回复…
发表回复
latimerjie9 2009-09-23
  • 打赏
  • 举报
回复
过路的
sy_binbin 2009-09-23
  • 打赏
  • 举报
回复
[Quote=引用 5 楼 sunsbn 的回复:]
引用 3 楼 sy_binbin 的回复:
title = request("title")
sql = "select * from info where class_id=1 and title = '"&title&"'"
rs.open sql,conn,1,1
if not(rs.bof and rs.eof) then
  response.write "重复了"
else
  response.write "没重复"
end if
是这个意思不


能帮我写出class_id=另外一个表的ID来的语句吗?
[/Quote]


另外一个表里的???什么意思???
sunsbn2 2009-09-22
  • 打赏
  • 举报
回复
谁能帮我解答。
homel 2009-09-22
  • 打赏
  • 举报
回复
[code=VBScript]<%'如果form处理方式为post

dim classid,title
classid=request.form("classid")
title=request.form("title")
set rs=server.CreateObject("adodb.recordset")
sql="select * from info where title='"&title&"' and classid="&classid
sql2="insert into info(title,classid) values('"&title&"',"&classid&")" '此处为你要做的操作
rs.open sql,conn,1,1
if not rs.eof then
response.Write("已经存在")
else
rs.open sql2,conn,1,2
end if%>[code=code]
zzhqiao 2009-09-22
  • 打赏
  • 举报
回复
select class_id,name from info where class_id in(select distinct id from class) group by class_id,name having count(*)=1 order by class_id
name是info中内容字段,这样查出来的是没有重复的。
lbcleo 2009-09-22
  • 打赏
  • 举报
回复
select H.*,X.* from info H,class X where H.user_id = X.user_id
黑心 2009-09-22
  • 打赏
  • 举报
回复
回复一下。拿分走人。
sunsbn2 2009-09-21
  • 打赏
  • 举报
回复
[Quote=引用 3 楼 sy_binbin 的回复:]
title = request("title")
sql = "select * from info where class_id=1 and title = '"&title&"'"
rs.open sql,conn,1,1
if not(rs.bof and rs.eof) then
  response.write "重复了"
else
  response.write "没重复"
end if
是这个意思不
[/Quote]

能帮我写出class_id=另外一个表的ID来的语句吗?
babycry627 2009-09-21
  • 打赏
  • 举报
回复
把要判断的那个值在数据库里面查询一下 有记录就不操作 没有记录就操作
sy_binbin 2009-09-21
  • 打赏
  • 举报
回复
title = request("title")
sql = "select * from info where class_id=1 and title = '"&title&"'"
rs.open sql,conn,1,1
if not(rs.bof and rs.eof) then
response.write "重复了"
else
response.write "没重复"
end if
是这个意思不
凡夫与俗子 2009-09-21
  • 打赏
  • 举报
回复
what do you want?
shenzhenNBA 2009-09-21
  • 打赏
  • 举报
回复
晕,好象LZ只讲条件,但你没有说你要做什么

28,406

社区成员

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

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