비교적 좋 은 asp 단일 폼 필드 다 중 조건 조회

용도:문장 표 내 글 키워드 조회 조회 형식: 바 이 두 google 바 이 두 가 좋 습 니까?구 글 이 좋 습 니까?바 이 두+구 글(조건 을 입력 하지 않 고 모두 조회 할 수 있 습 니 다) <% Function SearshSQL(Tname,Lname,Str) 'Tname-표 이름 Lname-열 이름 Str-조회 문자 If Trim(Str)="" then         MySql="Select * From "&Tname Else                 Str=SqlEncode(Str)                         '사전 처리 조회 문자열        ArrStr=split(Str," ")                '공백 분할 처리 후 문자열        Umax=Ubound(ArrStr)                        '분할 후 배열 의 상위,키워드 로 나 누 는 개 수 를 확정 합 니 다.        If Umax>0 Then                                '키워드 중 여러 개의 빈 칸 처리,2 차원 부터 처리                For i=1 to Umax                  StrTemp=ArrStr(i)                  If Trim(StrTemp)="" Then StrTemp="/~~~~~/" '분 단 된 요 소 는 빈 특수 문자 로 대체 합 니 다.                 Sql=Sql &" Or "& Lname &" like '%"& StrTemp &"%'"                 Next         End If         MySql="Select * From "& Tname &" where "& Lname &" like '%"&ArrStr(0)&"%'"&Sql         Do           j=InStr(1,MySql, "%/~~~~~/%",1)           If j=0 Then                 Exit Do           End If           MySql=Replace(MySql," Or "&Lname&" like '%/~~~~~/%'","")         Loop End IF         SearshSQL=MySql end function Function SqlEncode(Str)                '포맷 문자열 str=replace(str,"," ")        '먼저 좌우 의 전각 빈 칸 을 반 각 빈 칸 str=trim(str)str=replace(str,"["," ") str=replace(str,"';"," ") str=replace(str,"'"," ") str=replace(str,"_"," ") str=replace(str,"%"," ") str=replace(str,"+"," ") str=replace(str," "," ") sqlencode=str end function%><%sql=SearshSQL("article","coments","무+배추 곰") +"order by..(정렬)"Set rs=Server.Createobject("ADODB.RECORDSET") rs.Open sql,conn,1,1 if not rs.eof 다음

좋은 웹페이지 즐겨찾기