SimpleDB—子查询或嵌套的选择语句



我尝试在Amazon SimpleDB中实现以下查询,得到InvalidQueryExpression, AWS Error Message:指定的查询表达式语法不合法。

SelectRequest selectRequest = 
   new SelectRequest("select itemName() from Quotes where name = '" + 
      myName + 
      "' and name in (select followedName from Following)");

是子查询或嵌套选择根本不支持SimpleDB?那么,在不切换数据库的情况下,我怎样才能完成这样的事情呢?

所以我找到https://forums.aws.amazon.com/thread.jspa?messageID=236456𹮨,它说它不支持子查询。下面是我使用的变通方法:

SelectRequest selectRequestNames = new SelectRequest("select followedName from Following where followedBy = '" + myName + "'").withConsistentRead(true);
List<Item> names = getInstance().select(selectRequestNames).getItems();
String set = "(";
for (int j = 0; j < names.size(); j++) {
    set += "'" + names.get(j).getAttributes().get(0).getValue() + "',";
}
set = set.substring(0, set.length() - 1) + ")";
SelectRequest selectRequest = new SelectRequest("select itemName() from Quotes where fbName in " + set + " and timestamp is not null order by timestamp desc").withConsistentRead(true);

相关内容

  • 没有找到相关文章

最新更新