Chinaunix首页 | 论坛 | 博客
  • 博客访问: 853808
  • 博文数量: 117
  • 博客积分: 2595
  • 博客等级: 少校
  • 技术积分: 1204
  • 用 户 组: 普通用户
  • 注册时间: 2009-09-18 18:16
文章分类

全部博文(117)

文章存档

2013年(1)

2012年(2)

2011年(18)

2010年(95)

2009年(1)

分类: 数据库开发技术

2010-07-20 22:00:48

sql的嵌入式查询主要用于多个数据库表的交集查询!






                
                sql="select * from main where m_pass='1'" 
                sql =sql&"AND sellname like '%"&keyword&"%'"
                sql=sql&" AND mytype like '%"&mytype1&"%' "
                sql=sql&" AND selltype like '%"&selltype1&"%' "
                sql=sql&" AND remark like '%"&keyword&"%'"
                                
                if StrComp(nclassid1,"") then
                '    response.write "1 anclassid1="&nclassid1&"
"
                    sql=sql&" AND anclassid like '
%"&anclassid1&"%' "
                else'
不相等 -1 1
                    sql=sql&" OR anclassid in (select anclassid from shop_anclass where anclass like '%"&keyword&"%')"
                end if
                
                if StrComp(nclassid1,"") then
                '    response.write "1 nclassid1="&nclassid1&"
"
                    sql=sql&" AND nclassid like '
%"&nclassid1&"%' "
                else
                    sql=sql&" OR nclassid in (select nclassid from shop_nclass where nclass like '
%"&keyword&"%')"
                end if
                
                if StrComp(classid1,"") then
                '
    response.write "1 classid1="&classid1&"
"

                    sql=sql&" AND classid like '%"&classid1&"%' "
                else
                    sql=sql&" OR classid in (select classid from shop_class where class like '%"&keyword&"%')"
                end if


                sql=sql&" order by id desc"                     


阅读(1565) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~