0

I tried to implement the following query in Amazon SimpleDB and got InvalidQueryExpression, AWS Error Message: The specified query expression syntax is not valid.

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

Are subqueries or nested selects simply not supported u SimpleDB? Ff so, how can I accomplish something like that short of switching databases?

Luca Sepe
  • 2,435
  • 1
  • 20
  • 26
Phillip Godzin
  • 660
  • 1
  • 9
  • 21

1 Answers1

0

So I found https://forums.aws.amazon.com/thread.jspa?messageID=236456&#236456 which says that it doesn't support subqueries. Here's the workaround I used:

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);
Phillip Godzin
  • 660
  • 1
  • 9
  • 21