我不确定该用什么术语,但是我有一个mysql查询
SELECT name, invTypes.typeName, character_skills.trained_skill_level FROM character_skills INNER JOIN character_infos ON character_infos.character_id = character_skills.character_id INNER JOIN invTypes ON character_skills.skill_id = invTypes.typeID WHERE character_skills.active_skill_level <5 AND skill_id = 12203 AND name = 'Mokey PYD';
但是,有2个变量会发生变化,我需要在一个表上显示所有这些变量。
这两个变量是
WHERE character_skills.active_skill_level <5 AND skill_id = 12203
例如
我需要查看active_skill_level is < 5
的{{1}}的值,但还需要检查skill_id 12203
的{{1}}是否也要显示在同一张表上。 ..
有人可以帮我一点忙吗?非常感谢。
答案 0 :(得分:4)
使用UNION ALL
SELECT name, invTypes.typeName, character_skills.trained_skill_level
FROM character_skills INNER JOIN character_infos ON character_infos.character_id = character_skills.character_id
INNER JOIN invTypes ON character_skills.skill_id = invTypes.typeID
WHERE character_skills.active_skill_level <5 AND skill_id = 12203 AND name = 'Mokey PYD'
union all
SELECT name, invTypes.typeName, character_skills.trained_skill_level
FROM character_skills INNER JOIN character_infos ON character_infos.character_id = character_skills.character_id
INNER JOIN invTypes ON character_skills.skill_id = invTypes.typeID
WHERE character_skills.active_skill_level <4 AND skill_id = 12204 AND name = 'Mokey PYD'
答案 1 :(得分:3)
联合所有条件的替代方法是OR子句
SELECT name, invTypes.typeName
, character_skills.trained_skill_level
FROM character_skills
INNER JOIN character_infos ON character_infos.character_id = character_skills.character_id
INNER JOIN invTypes ON character_skills.skill_id = invTypes.typeID
WHERE ( character_skills.active_skill_level <5
AND skill_id = 12203 )
OR ( character_skills.active_skill_level <4
AND skill_id = 12204 )
AND name = 'Mokey PYD';