gpt4 book ai didi

MySql 查询 AND 和 OR 的组合

转载 作者:行者123 更新时间:2023-11-29 03:50:45 24 4
gpt4 key购买 nike

我想编写一个 MySql 查询,其中我想使用 AND 和 OR 的组合。我有 6 个属性,其中我希望出现一个字符串,并且有一个属性应该出现强制线程。

我的命令是这样的。

Select * from Students where roll_no like '__2011%' and subject1 ='maths' or subject2='maths' or subject3='maths' or subject4='maths' or subject5='maths' or subject6='maths';

我希望“数学”至少出现在这些主题属性之一中。连同那个 Roll no 应该有 2011 ,如查询中指定的那样。请帮助我。

最佳答案

Select * from Students where roll_no like '__2011%' and (subject1 ='maths' or subject2='maths' or subject3='maths' or subject4='maths' or subject5='maths' or subject6='maths');

关于MySql 查询 AND 和 OR 的组合,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9640122/

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