gpt4 book ai didi

mysql - 多个 AND/OR 逻辑困惑

转载 作者:行者123 更新时间:2023-11-29 07:12:50 25 4
gpt4 key购买 nike

我需要在 userID=4 和 status=“正在使用”、“待处理”或“已删除”时获取数据。但我得到了额外的数据,不知道为什么。

我从

获取额外数据
userid=3

MySQL 查询是:

SELECT * FROM `registered_bicycle` 
WHERE (`userID`='4')
AND (`status`='In Use')
OR (`status`='Pending')
OR (`status`='Deleted')

enter image description here

最佳答案

您必须在 OR 语句周围使用 (...):

SELECT * FROM `registered_bicycle` 
WHERE (`userID`='4')
AND (`status`='In Use'
OR `status`='Pending'
OR `status`='Deleted')

或使用IN函数

关于mysql - 多个 AND/OR 逻辑困惑,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39012368/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com