我正在使用Amazon Web Services API与SimpleDB域进行交互。相关代码为
selectExpression = "SELECT * FROM myDomain";
selectRequestAction = new SelectRequest().WithSelectExpression(selectExpression)
.WithNextToken(nextToken);
selectResponse = sdb.Select(selectRequestAction);
在这一点上,我迭代每个返回的行,并做一些时髦的事情。我的桌子是这样的:
| Name | AAA | BBB | CCC |
-------------------------------
| 519515 | fox | 311 | 1111 |
| 216165 | cbs | 971 | 1112 |
| 618105 | nbc | 035 | 1113 |
| 187655 | npr | 851 | 1114 |
| 551973 | npr | 654 | 1115 |
| 018583 | cbs | 302 | 1116 |
| 284801 | www | 762 | 1117 |
基本上,我想返回前5个AAA中AAA所在的所有行。例如,如果有:
- 1000行,其中AAA为"cbs"
- 800,其中AAA为"elo"
- 400,其中AAA为"npr"
- 304,其中AAA为"www"
- 200,其中AAA是"狐狸"
和
- 100,其中AAA为"qwe"
我想返回AAA为"cbs"、"elo"、"npr"、"www"或"fox"的所有行。
谢谢!
我从你的问题中了解到,你需要以下输出-
| AAA |
---------
| fox |
| cbs |
| elo |
| www |
| npr |
为此,您必须单独运行这些查询-
select * from `myDomain` where `AAA` = 'cbs' order by `AAA` asc limit 1
select * from `myDomain` where `AAA` = 'fox' order by `AAA` asc limit 1
select * from `myDomain` where `AAA` = 'elo' order by `AAA` asc limit 1
select * from `myDomain` where `AAA` = 'www' order by `AAA` asc limit 1
select * from `myDomain` where `AAA` = 'npr' order by `AAA` asc limit 1
一旦获得AAA属性的前5个值,就可以使用此查询
select * from `myDomain` where `AAA` in('cbs','fox','elo', 'www', 'npr')
这将返回AAA为"cbs"、"elo"、"npr"、"www"或"fox"的所有行。