SQL字段内容含有HTML标签,如何模糊查询
1个回答
展开全部
代码是在VC++里面:
[cpp] view plaincopyprint?
CString sql, str;
sql.Format(_T("SELECT * FROM tbPatient WHERE admitDate BETWEEN CDate('%s %s') AND CDate('%s %s')"),
dtStartDate.Format(_T("%x")), dtStartTime.Format(_T("%X")),
dtEndDate.Format(_T("%x")), dtEndTime.Format(_T("%X")));
//字段合并的模糊查询 MYSQL concat(email,address) like 'like%df%'
if(!strKeyWord.IsEmpty())
{
//SQL Server中IsNull(expression, replace)有替换功能,
//Access需要结合IsNull ( expression ), iif (condition, value_if_true, value_if_false )函数
//str.Format(_T(" AND IsNull(name, ' ') & IsNull(Empid, ' ') LIKE '%%%s%%'"),
// strKeyWord.GetBuffer(0));
str.Format(_T(" AND iif(IsNull(name),' ',name) & iif(IsNull(Empid),' ',Empid) LIKE '%%%s%%'"),
strKeyWord.GetBuffer(0));
sql += str;
}
TRACE1("%s\n", sql);
[cpp] view plaincopyprint?
CString sql, str;
sql.Format(_T("SELECT * FROM tbPatient WHERE admitDate BETWEEN CDate('%s %s') AND CDate('%s %s')"),
dtStartDate.Format(_T("%x")), dtStartTime.Format(_T("%X")),
dtEndDate.Format(_T("%x")), dtEndTime.Format(_T("%X")));
//字段合并的模糊查询 MYSQL concat(email,address) like 'like%df%'
if(!strKeyWord.IsEmpty())
{
//SQL Server中IsNull(expression, replace)有替换功能,
//Access需要结合IsNull ( expression ), iif (condition, value_if_true, value_if_false )函数
//str.Format(_T(" AND IsNull(name, ' ') & IsNull(Empid, ' ') LIKE '%%%s%%'"),
// strKeyWord.GetBuffer(0));
str.Format(_T(" AND iif(IsNull(name),' ',name) & iif(IsNull(Empid),' ',Empid) LIKE '%%%s%%'"),
strKeyWord.GetBuffer(0));
sql += str;
}
TRACE1("%s\n", sql);
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询