英文:
How to select rows if data might not be ordered?
问题
如何从mod
表中选择Id
,即使查询中提供的数据顺序与我的SQLite数据库中的顺序不同?
mod
表:
Id | Secondary1 | Secondary2 | Secondary3 | Secondary4 |
---|---|---|---|---|
1 | offense | tenacity | speed | defense |
2 | offense | speed | protection | potency |
… | … | … | … | … |
例如,如果我有次要属性为speed、tenacity、defense和offense的mod,我希望查询的输出是"1"。
我为每个部分的排列组合(speed、tenacity、defense、offense;speed、defense、tenacity、offense;等等)制作了查询,但这不是一个简洁的解决方案,似乎有些过度。
英文:
How to select Id
from mod
table even if data given in the query is not in the same order as the one in my SQLite database?
mod
table:
Id | Secondary1 | Secondary2 | Secondary3 | Secondary4 |
---|---|---|---|---|
1 | offense | tenacity | speed | defense |
2 | offense | speed | protection | potency |
… | … | … | … | … |
For example if I have the mod with secondaries speed, tenacity, defense and offense I want the query output to be "1".
I made a query for every partial permutation (speed, tenacity, defense, offense; speed, defense, tenacity, offense; etc.) but it isn't a sexy solution and seems overkill.
答案1
得分: 1
一个简单的解决方案可以是多次使用 IN
。
例如:
select * from t
where Secondary1 in ('速度', '坚韧', '防御', '进攻')
and Secondary2 in ('速度', '坚韧', '防御', '进攻')
and Secondary3 in ('速度', '坚韧', '防御', '进攻')
and Secondary4 in ('速度', '坚韧', '防御', '进攻')
英文:
A simple solution could be to just use IN
multiple times.
For example:
select * from t
where Secondary1 in ('speed', 'tenacity', 'defense', 'offense')
and Secondary2 in ('speed', 'tenacity', 'defense', 'offense')
and Secondary3 in ('speed', 'tenacity', 'defense', 'offense')
and Secondary4 in ('speed', 'tenacity', 'defense', 'offense')
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论