[求助]如何实现这样的搜索功能
											有一个人口登记表 有若干字段现在我想利用四个条件进行搜索 :地区, 性别, 年龄, 学历
分别是下拉菜单:
如图:
 
					
				
			如果下拉菜单是“=请选择=”表示并没有加这个条件,如果有内容的,则添加这个条件
我不知道sql 代码应该如何写。。。
请问这种搜索怎么做呀???
或者谁有相似的源代码借给我参考一下。。
 
					
				
			 2007-08-04 16:52
	    2007-08-04 16:52
   2007-08-04 17:00
	    2007-08-04 17:00
  sql="select * from table where"    
if 条件1<>""      then sql=sql&" and ziduan1='"&条件1&"'" 
if 条件2<>""      then sql=sql&" and ziduan2='"&条件2&"'"
if 条件3<>""      then sql=sql&" and ziduan3 like '%"&条件3&"%'" 
if 条件4<>""      then sql=sql&" and ziduan4="&条件4
.
.                               '类推增加条件
.   
if 条件n<>""     then sql=sql&" and ziduann='"&条件n&"'"
sql=replace(sql,"where and","where")                                '判断当有条件不为空时,转换第一个where and 
if right(sql,5)="where" then sql=left(sql,clng(len(sql))-5)     '判断所有条件都为空时,去掉where
注:要分页时,分页程序里可以需要带上的条件可以这样写:
keywords="条件1="&条件1&"&条件2="&条件2&"&条件3="&条件3&"&条件4="&条件4

 2007-08-04 17:35
	    2007-08-04 17:35