附加二进制声明
BINARY field_name = '字'

解决方案 »

  1.   

    SELECT * FROM tablename WHERE BINARY UCASE(fieldname) like UCASE('%".$Key."%')
      

  2.   

    搜索核心代码是
    $lookartsql="select artID from article where ".$selectart." like '%".$keyword1."%'";请问UCASE()是自定义函数吗?我使用时出错说没有定义
      

  3.   

    $lookartsql="select artID from article where BINARY ".$selectart." like '%".$keyword1."%'";
      

  4.   

    这个也和mysql的编码有关系.
    你把 mysql 的  /etc/my.cnf (UNIX) 或者 winnt\my.ini (WINNT/2000/XP) 中的[mysqld] 部分添加一句
    default-character-set = gbk
    试试.
      

  5.   

    感谢 xuzuning(唠叨) phanx(向右走) ,问题已解决,可以结贴了
      

  6.   

    还是有问题,如果加了BINARY,就不能忽略大小搜索,从而又会导致不能搜索出一些该搜索出来的东西
      

  7.   

    select artID from article where INSTR(字段, '值')>0
      

  8.   

    先判断关键字,分中文和英文搜索语句,中文加BINARY,英文不用。
      

  9.   

    to:countstars(深空)  中英文混合查询呢?
      

  10.   

    没办法,目前MYSQL对中文的支持不太好,只好寄希望于MYSQL的新版本了
      

  11.   

    ASP//search.htm
    <HTML>
    <HEAD>
    <TITLE>文件搜索引擎</TITLE>
    </HEAD>
    <BODY>
    <CENTER>
    <FORM METHOD=POST ACTION="search.asp">
    <TABLE BGCOLOR="#CC6633" BORDER="0">
    <TR>
        <TD> <FONT COLOR="#FFFFFF"> 
        请输入所要搜索的字符串:
        <INPUT TYPE="text" NAME="SearchText" SIZE="22"></FONT> </TD>
        <TD><INPUT TYPE="submit" VALUE="确定">
        <INPUT TYPE="reset" VALUE="清除"></TD>
    </tr>
    </TABLE>
    </FORM>
    </CENTER>
    </BODY>
    </HTML>
    //search.asp
    <HTML>
    <HEAD>
    <TITLE>'<%=Request("SearchText")%>'的搜索结果</TITLE>
    </HEAD>
    <BODY>
    <B>'<%=Request("SearchText")%>'的搜索结果</B><BR>
    <%
    Const fsoForReading = 1
    Dim objFile, objFolder, objSubFolder, objTextStream
    Dim bolCase, bolFileFound, bolTagFound
    Dim strCount, strDeTag, strExt, strFile, strContent, strRoot, strTag, strText, strTitle, strTitleL
    strFile = ".asp .htm .html .js .txt .css"
    strRoot = "/"
    strText = Request("SearchText")
    strTag = Chr(37) & Chr(62)
    bolFileFound = False
    bolTagFound = False
    If Request("Case") = "on" Then bolCase = 0 Else bolCase = 1
    Set objFSO = Server.CreateObject("Scripting.FileSystemObject")
    RealPath=Server.MapPath(strRoot)
    VirtualPath="http://" & Request.ServerVariables("SERVER_NAME") 
    Set objFolder = objFSO.GetFolder(RealPath)
    schSubFol(objFolder)
    Sub schSubFol(objFolder)
    on error resume next
    For Each objFile in objFolder.Files
      If strText = "" Then Exit Sub
      If Response.IsClientConnected Then
        Set objTextStream = objFSO.OpenTextFile(objFile.Path,fsoForReading)
        strContent = objTextStream.ReadAll
        If InStr(1, strContent, strTag, bolCase) Then
        Else
          If Mid(objFile.Name, Len(objFile.Name) - 1, 1) = "." Then strExt = Mid(objFile.Name, Len(objFile.Name) - 1, 2)
          If Mid(objFile.Name, Len(objFile.Name) - 2, 1) = "." Then strExt = Mid(objFile.Name, Len(objFile.Name) - 2, 3)
          If Mid(objFile.Name, Len(objFile.Name) - 3, 1) = "." Then strExt = Mid(objFile.Name, Len(objFile.Name) - 3, 4)
          If Mid(objFile.Name, Len(objFile.Name) - 4, 1) = "." Then strExt = Mid(objFile.Name, Len(objFile.Name) - 4, 5)
          If InStr(1, strContent, strText, bolCase) And Instr(1, strFile, strExt, 1) Then
            If InStr(1, strContent, "<TITLE>", 1) Then 
              strTitle = Mid(strContent, InStr(1, strContent, "<TITLE>", 1) + 7, InStr(1, strContent, "</TITLE>", 1)) 
            Else 
              strTitle = "未命名"
            end if
            myFile=objFile.Path
            myFile=replace(myfile,RealPath,VirtualPath,1,-1,1)
            myFile=replace(myfile,"\","/")
            strCount = strCount + 1
            Response.Write "<DL><DT><B><I>"& strCount  &"</I></B> - <A HREF=" & myFile & ">" & strTitle & "</A></A></DT><BR><DD>" 
            strTitleL = InStr(1, strContent, "</TITLE>", 1) - InStr(1, strContent, "<TITLE>", 1) + 7
            strDeTag = ""
            bolTagFound = False
            Do While InStr(strContent, "<")
              bolTagFound = True
              strDeTag = strDeTag & " " & Left(strContent, InStr(strContent, "<") - 1)
              strContent = MID(strContent, InStr(strContent, ">") + 1)
            Loop
            strDeTag = strDeTag & strContent
            If Not bolTagFound Then strDeTag = strContent
            Response.Write replace(Mid(strDeTag, strTitleL, 200),strText,"<font color=red>" & strText & "</font>",1,-1,bolcase) 
            Response.Write "...<BR><b><FONT SIZE='2'>URL: " & myFile 
            Response.Write " - 上次修改时间: " & objFile.DateLastModified
            Response.Write " - " & FormatNumber(objFile.Size / 1024)
            Response.Write "Kbytes</FONT></b></DD></DL>" 
            bolFileFound = True
          End If
          objTextStream.Close
        End If
      End If
    Next
    End Sub
    For Each objSubFolder in objFolder.SubFolders
        schSubFol(objSubFolder)
    Next
    If Not bolFileFound then Response.Write "没有匹配结果"
    If bolFileFound then Response.Write "<B>搜索结束</B>"
    Set objTextStream = Nothing
    Set objFolder = Nothing
    Set objFSO = Nothing
    %>
    </BODY></HTML> 
      

  12.   

    还是有问题,如果加了BINARY,就不能忽略大小搜索,从而又会导致不能搜索出一些该搜索出来的东西