数据库中模糊查询

       模糊查询

     数据库中模糊查询,用“*”或者“?”代替单词中相应的字符,来模糊查询."*"匹配字符在数据库中可以用"%%"代替;"?"批判字符在数据库中可以用"_"代替.

实例代码:

 CString strFind = "";
 m_Rich.GetWindowText(strFind);
 strFind.Replace("*", "%%");
 strFind.Replace("?", "_");
  CString strSQL = "";
 strSQL.Format("select a.keycode as keycode,a.codeno as keycodeno,b.codevalue as codevalue,b.codeno as codeno from keycount as a,codevalue as b where a.keycode like '%s' and a.relaxno=b.ID order by a.keycode,a.id ",strFind);
BOOL bExcute = ExcuteDBSQL(strSQL);

你可能感兴趣的:(数据库)