Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[6.0.12 LTS]Db where生成的语句有误,指定in还是变成= #1114

Open
wuyifan66 opened this issue Sep 3, 2022 · 2 comments
Open

[6.0.12 LTS]Db where生成的语句有误,指定in还是变成= #1114

wuyifan66 opened this issue Sep 3, 2022 · 2 comments

Comments

@wuyifan66
Copy link

Db::table('think_user')
->where('id', 'IN', function ($query) {
$query->table('think_profile')->where('status', 1)->field('id');
})
->select();

这个查询的不是in,是=,怎么解决

同样
Db::table('think_user')
->where('id', 'IN', '(select user_id from think_vips)')
->select();

生成的语句为 select * from think_user where id = (select user_id from think_vips)
预期的则是 select * from think_user where id in (select user_id from think_vips)

@zcenet
Copy link

zcenet commented Sep 3, 2022 via email

@wuyifan66 wuyifan66 changed the title Db where生成的语句有误,指定in还是变成= [6.0.12 LTS]Db where生成的语句有误,指定in还是变成= Sep 3, 2022
@liu21st
Copy link
Member

liu21st commented Sep 15, 2022

这个写法建议用whereExp方法查询 in查询默认会自动识别 如果不是数组 就不用会用in

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants