我的过滤查询有问题。它非常复杂(对我来说至少:)) 所以这是一个生成的查询:
select `times`.*, `time_categories`.`name` as `type` from `times`
inner join `time_categories` on `times`.`time_category_id` = `time_categories`.`id`
where `item_id` in
(select `tickets`.`id` from `tickets`
where `tickets`.`client_id` = '3fb95c1c65b3aa8e197833bcb3741940')
or `item_id` in
(select tasks.id from tasks, client_project
where tasks.project_id = client_project.project_id
and `client_project`.`client_id` = '3fb95c1c65b3aa8e197833bcb3741940')
and `times`.`user_id` = 'c4065852240228f25e3272708c7824da'
and `times`.`network_id` = '502e43ad71e844b0d502bc9ac60816eb'
order by `times`.`start_time` desc
问题在于user_id,它总是返回一个条目,与其设置的user_id无关。
好像它与or' item_id'有关。部分。当我删除它,它返回正确。我不知道为什么它不包含查询的user_id。
任何人都可以帮忙吗?