Querying for multi-valued attributes
Retrieve all songs with a rating of 4 stars
or ****
:
SELECT * FROM songs WHERE Rating = '****' OR Rating = '4 stars'
To retrieve all songs with a rating of '4 stars'
and '****'
use:
SELECT * FROM songs WHERE Rating = '****' INTERSECTION Rating = '4 stars'
While it may seem logical to use AND, it is not syntactically acceptable to SimpleDB.
getAttribute
SELECT is the most common technique to retrieve items from SimpleDB, but one special case is retrieving one item using the item name. This can be done with a SELECT query, but getAttributes
uses about 41% of the box usage of the SELECT query.
getAttributes in Java
In this example, we will retrieve the attributes for an item from SimpleDB. Typica provides a method called getItemsAttributes()
, which uses getAttributes
under the covers.
SimpleDB sdb = new SimpleDB(awsAccessId, awsSecretKey, true); try { Domain domain = sdb.getDomain("songs"); List<String> itemsToGet = new ArrayList<String>(); itemsToGet...