将多行合并为1 [英] Combine multiple rows into 1

查看:73
本文介绍了将多行合并为1的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个包含deviceid,属性类型和属性值的表。单个设备ID有许多属性。我希望我的查询检索具有多个属性值的单个设备ID。到目前为止,这就是我所拥有的。

I have a table with a deviceid, attribute type, and attribute value. There are many attributes for a single device id. I want my query to retrieve a single device id with multiple attribute values. Here''s what I have so far.

展开 | 选择 | Wrap | 行号

推荐答案

@ aas4mis


这几乎是不可能的,它将是丑陋和缓慢的


你能规范化你的数据库吗,它将是一个更方便你
@aas4mis
This is very nearly impossible, it would be ugly and slow

Could you normalise your database, it will be a lot easier on you


在这里,阅读 this。正如您所看到的,您将需要一个可用于排序的密钥。但你应该知道它是如何完成的。


快乐编码!!!


~~ CK
Here, read this. As you can see, you''re going to need a key that can be used for sorting. But you should have some idea on how it''s done.

Happy Coding!!!

~~ CK


@gpl


否,无法正常化。这不是我的DB,实际上是由motorola设计的(并且用于他们的目的)。我正在制作一个自定义网页来与数据库进行交互,并且需要对存储过程进行此查询。我不知道这会有多慢,因为这张表中的总记录少于7,000。当然必须有一个干净的方式来写这个。 ......楼里有Shirley ???
@gpl
No, unable to normalize. This is not my DB, actually designed by motorola (and works for their purposes). I''m making a custom web page to interact with the database and need this query for a stored procedure. I don''t see where this would be slow as there are less than 7,000 total records in this table. Surely there must be a clean way to write this. ... is there are Shirley in the building???


这篇关于将多行合并为1的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆