【发布时间】:2011-08-04 15:04:39
【问题描述】:
假设我有一张这样的桌子
id | device | cmd | value |
------+----------------+-------+---------
id = unique row ID
device = device identifier (mac address)
cmd = some arbitrary command
value = value of corresponding command
我想以某种方式在此表上自行加入,以获取特定设备的特定 cmd 及其对应值。
我不想要SELECT cmd,value FROM table WHERE device='00:11:22:33:44:55';
说出我想要对应getname 和getlocation 命令的值。我想输出类似的东西
mac | name | location
--------------------+-----------+------------
00:11:22:33:44:55 | some name | somewhere
我的 sql fu 是漂亮的裤子。我一直在尝试不同的组合,例如 SELECT a.value,b.value FROM table AS a INNER JOIN table AS b ON a.device=b.device,但我一无所获。
感谢您的帮助。
【问题讨论】:
标签: postgresql join