关于ACCESS中用UNION多表查询

来源:百度知道 编辑:互助问答吧 时间:2019/10/24 00:01:14
if query<>"" then

sqltext1="select id,title,surl,squ from aboutus where language='1' and content like '%" & query & "%'"
sqltext2="select classid,classname,linkurl,squ from menuclass where classname like '%" & query & "%'"
sqltext3="select id,title,surl,squ from affiche where title like '%" & query & "%' or content like '%" & query & "%'"
sqltext4="select id,explain,surl,squ from comphonor where explain like '%" & query & "%'"
sqltext5="select id,title,surl,squ from contact where content like '%" & query & "%'"
sqltext6="select id,title,surl,squ from feedback where language='0' and publish<>'1' and (title like '%" & query & "%' or content like '%" & query &

"%' or refeedback like '%" & query & "%')"
sqltext7="select id,hrname,surl,squ from hrdemand where hrpublish=true and (hrbumen like '%" & query & "%' or hrname like '%" & query & "%' or

hrdetail like '%" & query & "%')"
sqltext8="select id,title,surl,squ from market where manpower like '%" & query & "%'"
sqltext9="select id,title,surl,squ from news where title like '%" & query & "%' or content like '%" & query & "%'"
sqltext10="select id,title,surl,squ from news where Passed=True and (title like '%" & query & "%' or content like '%" & query & "%')"

end if

sqltext=sqltext1 & " union all " & sqltext2 & " union all " & sqltext3 & " union all " & sqltext4 & " union all " & sqltext5 & " union all " &

sqltext6 & " union all " & sqltext7 & " union all " & sqltext8 & " union all " & sqltext9 & " union all " & sqltext10

if currentPage=1 then
sqlSearch="select top " & MaxPerPage & " * from (" & sqltext & ")"
else
sqlSearch="select * from (" & sqltext & ")"
end if

'response.write sqlsearch
'response.end
Set rsSearch= Server.CreateObject("ADODB.Recordset")
rsSearch.open sqlSearch,conn,1,1
俺才学的SQL语言,从网上找了资料,测试时,最后一句rsSearch.open sqlSearch,conn,1,1
无法运行,请高手指点