dqnf28092 2014-02-11 06:32
浏览 29

我可以在Mysql Query中使用PHP函数吗?

Following is my query and I would like to call PHP substr(); within Mysqlquery. Apparently, substr(ident.secondName, -2, 2) is working, but substr(ident.FirstName, 0, 2) is not working. Thank you in an advance!

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)");
  • 写回答

6条回答 默认 最新

  • drpsrvu85668 2014-02-11 06:34
    关注

    No you cannot use a PHP function in a MySQL query, see the MySQL function reference for strings instead. MySQL also happens to have a SUBSTR function which is why the first case works.

    评论

报告相同问题?

悬赏问题

  • ¥30 这是哪个作者做的宝宝起名网站
  • ¥60 版本过低apk如何修改可以兼容新的安卓系统
  • ¥25 由IPR导致的DRIVER_POWER_STATE_FAILURE蓝屏
  • ¥50 有数据,怎么建立模型求影响全要素生产率的因素
  • ¥50 有数据,怎么用matlab求全要素生产率
  • ¥15 TI的insta-spin例程
  • ¥15 完成下列问题完成下列问题
  • ¥15 C#算法问题, 不知道怎么处理这个数据的转换
  • ¥15 YoloV5 第三方库的版本对照问题
  • ¥15 请完成下列相关问题!