gpt4 book ai didi

mysql - 在我的 WHERE 子句条件中出现问题。 <> 和与或

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

我正在开发一种锻炼生成类型的应用程序,但我遇到了 mysql 查询问题。我遇到的问题是,当我在 where 子句中专门将它们作为 Not equal <> 时,我一直在获取超过 1 个特定的 ExerciseID。

SELECT `Exercise_Name` , `Body_Part_Focus` , `Video_FileName` , `Alignment_Body_Position` ,  `Description_Movement_Technique` , `Tip1_Trainer_Tips` , `Sets` , `Post_Season` , `Off_Season`, `Pre_Season` , `In_Season` , `Measurement_Type` , `Measurement_Type_Label` ,`ExerciseID` 
FROM `tbl_exercises` WHERE
`exrcs_age_approp` = '14 to 17'
AND `exrcs_prgssn_lvl` = 'I' OR `exrcs_prgssn_lvl` = 'II'
AND `Athletic_Skill` = 'ROM' OR `Exercise_Subskill` = 'ROM'
AND `Body_Part_Focus` = 'Torso'
AND `ExerciseID` <> 89
AND `ExerciseID` <> 58
AND `ExerciseID` <> 178
AND `ExerciseID` <> 249
ORDER BY RAND( ) LIMIT 0 , 1

我的 AND OR 子句是否正确?我想说这个和这个或这个和这个.. 等等.. 但我认为我的 mysql 也可能解释错误......我通常不接触后端的东西。

谢谢

最佳答案

这可能是因为您的 ANDOR 条件之间缺少括号。我使用 INNOT IN 对您的查询进行了一些简化:

SELECT `Exercise_Name` , `Body_Part_Focus` , `Video_FileName` , `Alignment_Body_Position` ,  `Description_Movement_Technique` , `Tip1_Trainer_Tips` , `Sets` , `Post_Season` , `Off_Season`, `Pre_Season` , `In_Season` , `Measurement_Type` , `Measurement_Type_Label` ,`ExerciseID` 
FROM `tbl_exercises`
WHERE `exrcs_age_approp` = '14 to 17'
AND `exrcs_prgssn_lvl` IN ('I', 'II')
AND (`Athletic_Skill` = 'ROM' OR `Exercise_Subskill` = 'ROM')
AND `Body_Part_Focus` = 'Torso'
AND `ExerciseID` NOT IN (89, 58, 178, 249)
ORDER BY RAND( ) LIMIT 0 , 1

关于mysql - 在我的 WHERE 子句条件中出现问题。 <> 和与或,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24223932/

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