我已经实现了一个mysql查询,其中有很多where条件,但是没有给出正确的结果。我必须找到用户id不等于7的数据,但是它给出了用户id为7的结果。下面是我运行的两个查询,但是没有给出正确的结果。
SELECT *
FROM `tr_truck`
WHERE (`user_id` != 7 AND `body_type_id` = 1 )
AND ( `truck_capacity_id` = 1 AND `truck_wheel_id` = 2 )
OR ( `truck_wheel_id` = 2 AND `truck_length_id` = 1 )
OR (`truck_capacity_id` = 1 AND `truck_length_id` = 1 )
我运行的另一个查询是
SELECT *
FROM `tr_truck`
WHERE ( `truck_capacity_id` = 1 AND `truck_wheel_id` = 2 )
OR ( `truck_wheel_id` = 2 AND `truck_length_id` = 1 )
OR (`truck_capacity_id` = 1 AND `truck_length_id` = 1 )
AND `user_id` NOT IN (7) AND `body_type_id` = 1
我还尝试用!=但没用。这是我数据库结果的截图。https://prnt.sc/kskl08
1条答案
按热度按时间jyztefdp1#
你能试试这个吗,我重新安排一下括号的排列
查询1
查询2