以下是我的查询,我想调用PHP substr();在Mysqlquery中。显然, substr(ident.secondName,-2,2)正在工作,但substr(ident.FirstName,0,2)不起作用。 谢谢您的提前!我可以在Mysql Query中使用PHP函数吗?
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)");
together.If要使用PHP函数,然后使用PHP变量不能混用PHP函数和MySQL变量,否则使用MySQL的功能与MySQL varaible only.In查询您要使用PHP函数'SUBSTR '用mysql变量这是错误的 – krishna