我尝试在Amazon SimpleDB中实现以下查询并获得InvalidQueryExpression,AWS错误消息:指定的查询表达式语法无效。
SelectRequest selectRequest =
new SelectRequest("select itemName() from Quotes where name = '" +
myName +
"' and name in (select followedName from Following)");
是否简单地不支持子查询或嵌套选择?SimpleDB?那么,我怎样才能实现像交换数据库这样的东西呢?
答案 0 :(得分:0)
所以我发现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);