下面是我的查询,我想在Mysqlquery中调用PHP substr();。显然,substr(ident.secondName,-2,2)正在工作,但是substr(ident.FirstName,0,2)不工作。提前谢谢你!
mysqli_query($con, "select * from ident where ident.FirstName LIKE '%$first_name%'
OR substr(ident.FirstName, 0, 2) = '$first_two' OR ident.FirstName IS NULL AND
(ident.SecondName LIKE '%$second_name%' OR substr(ident.SecondName, -2, 2)
= $second_two' OR ident.SecondName IS NULL)");发布于 2014-02-11 14:34:15
不,您不能在MySQL查询中使用PHP函数,请参阅MySQL function reference for strings。MySQL恰好也有一个SUBSTR函数,这就是第一种情况有效的原因。
发布于 2014-02-11 14:35:44
不是的。您不能在mysql中使用PHP函数。
发布于 2014-02-11 14:34:51
您将把查询传递给您的Mysql实例,它将无法识别PHP代码。所以是不通过的。
https://stackoverflow.com/questions/21694787
复制相似问题