有没有哪个高手提供一个通用组合查询的代码,要求能够检索出关键词

lusui666 2003-07-21 09:27:24
各位大虾,有没有人提供组合查询的程序,要求能够检索出关键词,比如能够检索出某年某个单位的某一本书,书名就需要用关键词来检索,又能提供的吗?不胜感激!
...全文
81 8 打赏 收藏 转发到动态 举报
写回复
用AI写文章
8 条回复
切换为时间正序
请发表友善的回复…
发表回复
hovoy 2003-07-23
  • 打赏
  • 举报
回复
回复人: takeiteasy(takeiteasy

同意说的
takeiteasy 2003-07-23
  • 打赏
  • 举报
回复
其实你自己可以尝试做一个比较通用的查询,以方便自己以后的使用,对你自己而言,也是水平的提高啊。
lusui666 2003-07-23
  • 打赏
  • 举报
回复
再看看我用下拉菜单做的,一样不能实现检索出“关键词“(gjc)这一列中关键词的检索输出,所以才请教你们的,程序如下:
/定义查询的列
string lookforitem1,lookforitem2,lookforitem3
//定义查询符号
string lookforhow1,lookforhow2,lookforhow3
//定义查询内容
string lookforwhat1,lookforwhat2,lookforwhat3
//定义组合操作符号
string operation1,operation2

//查询符号的选择
lookforhow1=ddlb_4.text
lookforhow2=ddlb_5.text
lookforhow3=ddlb_6.text
//操作符号的选择
if ddlb_7.text="与" then
operation1="and"
end if
if ddlb_8.text="与" then
operation2="and"
end if
//查询字段1和查询内容1的选择
if ddlb_1.text="关键词" then
lookforitem1="gjc"
lookforwhat1="'%"+sle_1.text+"%'"
elseif ddlb_1.text="国籍" then
lookforitem1="gj"
lookforwhat1="'"+sle_1.text+"'"
elseif ddlb_1.text="日期" then
lookforitem1="cbrq"
lookforwhat1=sle_1.text
elseif ddlb_1.text="出版单位" then
lookforitem1="zlly"
lookforwhat1="'"+sle_1.text+"'"
end if
//查询字段2和查询内容2的选择
if ddlb_2.text="国籍" then
lookforitem2="gj"
lookforwhat2="'"+sle_2.text+"'"
elseif ddlb_2.text="日期" then
lookforitem2="cbrq"
lookforwhat2=sle_2.text
elseif ddlb_2.text="出版单位" then
lookforitem2="zlly"
lookforwhat2="'"+sle_2.text+"'"
end if
//查询字段3和查询内容3的选择

if ddlb_3.text="国籍" then
lookforitem3="gj"
lookforwhat3="'"+sle_3.text+"'"
elseif ddlb_3.text="日期" then
lookforitem3="cbrq"
lookforwhat3=sle_3.text
elseif ddlb_3.text="出版单位" then
lookforitem3="zlly"
lookforwhat3="'"+sle_3.text+"'"
end if
if ddlb_1.text="" or ddlb_4.text="" then
elseif ddlb_2.text="" or ddlb_5.text="" then
lookforcondition=lookforitem1+lookforhow1+""+lookforwhat1+""
elseif ddlb_3.text="" or ddlb_6.text="" then
lookforcondition=lookforitem1+lookforhow1+""+lookforwhat1+""+operation1+" "+lookforitem2+lookforhow2+""+lookforwhat2+""
else
lookforcondition=lookforitem1+lookforhow1+""+lookforwhat1+""+operation1+" "+lookforitem2+lookforhow2+""+lookforwhat2+""+operation2+" "+lookforitem3+lookforhow3+""+lookforwhat3+""
end if
dw_1.setfilter(lookforcondition)
dw_1.filter()
dw_1.retrieve()
if dw_1.rowcount()=0 then
messagebox("系统提示:","对不起,数据库中无记录!")
return
end if
lusui666 2003-07-23
  • 打赏
  • 举报
回复
各位大虾,我又何尝不想做一个呢,你们看看我用三个复选按钮做的查询,就是不能组合查询,只能单个查询,你们看看什么毛病?

string ls_temp1,ls_temp2,ls_temp3
string ls_filter,ls_filter1,ls_filter2,ls_filter3
if cbx_1.checked =true then
ls_temp1=trim(sle_1.text)
ls_filter1=''
if pos(ls_temp1,'',1) > 0 then
ls_filter1=ls_filter1+"gjc like'"+trim(left(ls_temp1,pos(ls_temp1,'',1)))+"'and"
ls_temp1=replace(ls_temp1,1,pos(ls_temp1,'',1),'')
else
ls_filter1="gjc like'"+ls_temp1+"'"
ls_temp1=''
end if
end if
if cbx_2.checked =true then
ls_temp2=trim(sle_2.text)
ls_filter2=''
if pos(ls_temp2,'',1) > 0 then
ls_filter2=ls_filter2+"gj like'"+trim(left(ls_temp2,pos(ls_temp2,'',1)))+"'and"
ls_temp2=replace(ls_temp2,1,pos(ls_temp2,'',1),'')
else
ls_filter2="gj like'"+ls_temp2+"'"
ls_temp2=''
end if
end if
if cbx_3.checked =true then
ls_temp3=trim(sle_3.text)
ls_filter3=''
if pos(ls_temp1,'',1) > 0 then
ls_filter3=ls_filter3+"cbrq like'"+trim(left(ls_temp3,pos(ls_temp3,'',1)))+"'and"
ls_temp3=replace(ls_temp3,1,pos(ls_temp3,'',1),'')
else
ls_filter3="cbrq like'"+ls_temp3+"'"
ls_temp3=''
end if
end if
if cbx_1.checked=true then
if cbx_2.checked=false and cbx_3.checked=false then
ls_filter=ls_filter1
end if
elseif cbx_2.checked=true then
if cbx_1.checked=false and cbx_3.checked=false then
ls_filter=ls_filter2
end if
elseif cbx_3.checked=true then
if cbx_1.checked=false and cbx_2.checked=false then
ls_filter=ls_filter3
end if
elseif cbx_1.checked=true and cbx_2.checked=true then
if cbx_3.checked=false then
ls_filter=""+ls_filter1+""+"and"+" "+ls_filter2+""
end if
elseif cbx_1.checked=true and cbx_3.checked=true then
if cbx_2.checked=false then
ls_filter=""+ls_filter1+""+"and"+" "+ls_filter3+""
end if
elseif cbx_2.checked=true and cbx_3.checked=true then
if cbx_1.checked=false then
ls_filter=""+ls_filter2+""+"and"+" "+ls_filter3+""
end if
else
ls_filter=""+ls_filter1+""+"and"+" "+ls_filter2+""+"and"+" "+ls_filter3+""
end if
//过滤输出
dw_1.setfilter(ls_filter)
dw_1.filter()
//检索显示
dw_1.SetTransObject(sqlca)
dw_1.retrieve()
if dw_1.rowcount()=0 then
messagebox("系统提示:","对不起,数据库中无记录!")
return
end if
紫炎圣骑 2003-07-23
  • 打赏
  • 举报
回复
自己做一个多好呀!!

对自己及时锻炼也是一个很好的提高!!

何乐而不为?!

相信做好后,你的水平会大涨的!
lusui666 2003-07-22
  • 打赏
  • 举报
回复
请问那里可以下载?
klbt 2003-07-21
  • 打赏
  • 举报
回复
自己做一个吧。
runsoft 2003-07-21
  • 打赏
  • 举报
回复
down一个万能查询吧。

752

社区成员

发帖
与我相关
我的任务
社区描述
PowerBuilder 数据库相关
社区管理员
  • 数据库相关社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

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