You want to find the same data as the second-to-last value of the UID
Like what
1000000005
1000000006
1000000007
1000000008
1000000023//different do not
1000000009
To implement such logic, what to do
$uid = I('get.uid', 0, 'intval');//假设用户ID:1000000005$where['uid'] = substr($uid, -2,1);//倒数第二位:0$res = M('code')->where($where)->select();//这样做实现不了
Reply content:
You want to find the same data as the second-to-last value of the UID
Like what
1000000005
1000000006
1000000007
1000000008
1000000023//different do not
1000000009
To implement such logic, what to do
$uid = I('get.uid', 0, 'intval');//假设用户ID:1000000005$where['uid'] = substr($uid, -2,1);//倒数第二位:0$res = M('code')->where($where)->select();//这样做实现不了
$where['uid'] = 'substr('+$uid+', -2,1)';
Add quotation marks to try, do not add quotation marks into PHP function, MySQL also has the SUBSTR function
You're going to generate a statement like this.
select * from `character` where SUBSTR(characterId, -2, 1) ='1'