| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 3141 人关注过本帖
标题:[求助]实现好多项的sql与或非高级查询!
只看楼主 加入收藏
yanziyz
Rank: 1
等 级:新手上路
帖 子:171
专家分:0
注 册:2006-5-20
收藏
得分:0 

谢谢各位的帮助!在大家的提示下,特别是islet, 我的高级查询系统已经做好了

我把主要的sql语句写出来,但愿对和我有类似问题的朋友有所帮助!

select case strxuewei
case "全部"
strsql="select * from xwlwtj where 1=1"
case "硕士"
strsql="select * from xwlwtj where Xuewei='硕士'"
case "博士"
strsql="select * from xwlwtj where Xuewei='博士'"
case else
strsql="select * from xwlwtj where 1=1"
end select

if strtext1<>"" then

select case strhigh1
case "论文题名"
strsql=strsql&"And (Chntitle like '%"&strtext1&"%' "
case "论文作者"
strsql=strsql&"And Name='"&strtext1&"' "
case "导师"
strsql=strsql&"And Teachername1='"&strtext1&"'"
case "学科专业"
strsql=strsql&"And Major like '%"&strtext1&"%'"
case "关键词"
strsql=strsql&"and Keyword like '%"&strtext1&"%'"
case "中文摘要"
strsql=strsql&"and AbstructCH like '%"&strtext1&"%'"
case "提交年份"
strsql=strsql&"and Datetime like '%"&strtext1&"%'"
'case "分类号"
'strsql=strsql& "and Datetime like '%"&strtext1&"%'"
'case "全文"
'strsql=strsql& "and Datetime like '%"&strtext1&"%'"
end select
end if

if strtext2<>"" then
If strhigh2<>"not" then


select case strhigh3
case "论文题名"
strsql=strsql& ""&strhigh2&" Chntitle like '%"&strtext2&"%'"
case "论文作者"
strsql=strsql& ""&strhigh2&" Name='"&strtext2&"'"
case "导师"
strsql=strsql& ""&strhigh2&" Teachername1='"&strtext2&"'"
case "学科专业"
strsql=strsql& ""&strhigh2&" Major like '%"&strtext2&"%'"
case "关键词"
strsql=strsql& ""&strhigh2&" Keyword like '%"&strtext2&"%'"
case "中文摘要"
strsql=strsql& ""&strhigh2&" AbstructCH like '%"&strtext2&"%'"
case "提交年份"
strsql=strsql& ""&strhigh2&" Datetime like '%"&strtext2&"%'"
case "分类号"
strsql=strsql& ""&strhigh2&" Datetime like '%"&strtext2&"%'"
case "全文"
strsql=strsql& ""&strhigh2&" Datetime like '%"&strtext2&"%'"
end select
else
select case strhigh3
case "论文题名"
strsql=strsql& "and Chntitle not like '%"&strtext2&"%'"
case "论文作者"
strsql=strsql& "and Name!='"&strtext2&"'"
case "导师"
strsql=strsql& "and Teachername1!='"&strtext2&"'"
case "学科专业"
strsql=strsql& "and Major not like '%"&strtext2&"%'"
case "关键词"
strsql=strsql& "and Keyword not like '%"&strtext2&"%'"
case "中文摘要"
strsql=strsql& "and AbstructCH not like '%"&strtext2&"%'"
case "提交年份"
strsql=strsql& "and Datetime not like '%"&strtext2&"%'"
case "分类号"
strsql=strsql& "and Datetime not like '%"&strtext2&"%'"
case "全文"
strsql=strsql& "and Datetime not like '%"&strtext2&"%'"
end select
end if

end if

if strtext3<>"" then
if strhigh4<>"not" then

select case strhigh5
case "论文题名"
strsql=strsql& ""&strhigh4&" Chntitle like '%"&strtext3&"%'"
case "论文作者"
strsql=strsql& ""&strhigh4&" Name='"&strtext3&"'"
case "导师"
strsql=strsql& ""&strhigh4&" Teachername1='"&strtext3&"'"
case "学科专业"
strsql=strsql& ""&strhigh4&" Major like '%"&strtext3&"%'"
case "关键词"
strsql=strsql& ""&strhigh4&" Keyword like '%"&strtext3&"%'"
case "中文摘要"
strsql=strsql& ""&strhigh4&" AbstructCH like '%"&strtext3&"%'"
case "提交年份"
strsql=strsql& ""&strhigh4&" Datetime like '%"&strtext3&"%'"
case "分类号"
strsql=strsql& ""&strhigh4&" Datetime like '%"&strtext3&"%'"
case "全文"
strsql=strsql& ""&strhigh4&" Datetime like '%"&strtext3&"%'"
end select
else

select case strhigh5
case "论文题名"
strsql=strsql& "and Chntitle not like '%"&strtext3&"%'"
case "论文作者"
strsql=strsql& "and Name!='"&strtext3&"'"
case "导师"
strsql=strsql& "and Teachername1!='"&strtext3&"'"
case "学科专业"
strsql=strsql& "and Major not like '%"&strtext3&"%'"
case "关键词"
strsql=strsql& "and Keyword not like '%"&strtext3&"%'"
case "中文摘要"
strsql=strsql& "and AbstructCH not like '%"&strtext3&"%'"
case "提交年份"
strsql=strsql& "and Datetime not like '%"&strtext3&"%'"
case "分类号"
strsql=strsql& "and Datetime notlike '%"&strtext3&"%'"
case "全文"
strsql=strsql& "and Datetime not like '%"&strtext3&"%'"
end select
end if

end if


2006-06-08 15:23
tang688
Rank: 5Rank: 5
等 级:贵宾
威 望:16
帖 子:1219
专家分:35
注 册:2004-12-25
收藏
得分:0 
islet的法很好啊。
不用你写的这么复杂的。

2006-06-09 08:46
tang688
Rank: 5Rank: 5
等 级:贵宾
威 望:16
帖 子:1219
专家分:35
注 册:2004-12-25
收藏
得分:0 
我也常用这个办法的啊

2006-06-09 08:47
快速回复:[求助]实现好多项的sql与或非高级查询!
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.028620 second(s), 7 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved