如何在 1 个查询中选择与同一列中的多个元素匹配的不同行?
ID object type
1 1 u
2 1 x
3 1 z
4 2 z
5 2 t
6 4 x
7 4 u
8 4 t
假设我有这组数据,我想要得到的是所有与某些可变数量的类型匹配的不同对象,并按匹配的类型数量对它们进行排序。全部在 1 个查询中。
假设我想要 u,x,t 类型的对象。我想从与所有匹配的对象到仅与一合一查询匹配的对象中按降序选择它们。如果有任何人可以提供帮助,我正在使用 mysql ...
ID object type
1 1 u
2 1 x
3 1 z
4 2 z
5 2 t
6 4 x
7 4 u
8 4 t
Asuming i have that set of data , what i want to get is all distinct objects that would match some variable number of types, and order them by the number of types that matched. All in 1 query.
So lets say i want the objects that are of type u,x,t . I want to select them in descendent order from the object that matched all to the one that matched only 1 in 1 query. If any1 can help, im using mysql ...
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
干得好:
here you go:
不确定我明白你想做什么,但我想这会导致:
Not sure i understand what you trying todo but i guess it will lead to: