In the previous sections, you queried for items with the attribute Category that contain the value Clothes. This section provides examples of how to write a query using multiple attributes.
The following sample code snippets demonstrate querying for items with the attribute Make that contain the value Audi and the attribute Model that contain the value S4.
To run the sample
Open a clean copy of QuerySample.java.
Remove any comment marks from the invokeQuery(service, request); line and add the following lines
after // @TODO: set request parameters here:
String queryExpression = "['Make' = 'Audi'] intersection ['Model' = 'S4']";
request.withDomainName("MyStore").withQueryExpression(queryExpression);Compile and run the sample.
Amazon SimpleDB returns items with the attribute Make that contain the value Audi and the attribute Model that contain the value S4.
To view the attributes of the returned items, see Getting the Attributes of an Item.
To run the sample
Open AmazonSimpleDBSamples.cs.
Comment out the code you added in the previous section.
Add the following to the Query Action section:
String queryExpressionMultiAttribute = "['Make' = 'Audi'] intersection ['Model' = 'S4']";
Query multiAttributeQueryAction = new Query().WithDomainName("MyStore").WithQueryExpression(queryExpressionMultiAttribute);
QuerySample.InvokeQuery(service, multiAttributeQueryAction);Run the sample.
Amazon SimpleDB returns items with the attribute Make that contain the value Audi and the attribute Model that contain the value S4.
To view the attributes of the returned items, see Getting the Attributes of an Item.
To run the sample
Open a clean copy of QuerySample.pl.
Remove any comment marks from the invokeQuery($service, $request); line and add the following lines
after the // @TODO: set request parameters here line:
my $request = Amazon::SimpleDB::Model::Query->new();
$request->setDomainName('MyStore');
$request->setQueryExpression("['Make' = 'Audi'] intersection ['Model' = 'S4']");
Run the sample.
Amazon SimpleDB returns items with the attribute Make that contain the value Audi and the attribute Model that contain the value S4.
To view the attributes of the returned items, see Getting the Attributes of an Item.
To run the sample
Open a clean copy of QuerySample.php.
Remove any comment marks from the invokeQuery($service, $request); line and add the following lines
after the // @TODO: set request parameters here line:
$request = new Amazon_SimpleDB_Model_Query();
$request->setDomainName('MyStore');
$request->setQueryExpression('[\'Make\' = \'Audi\'] intersection [\'Model\' = \'S4\']');
Run the sample.
Amazon SimpleDB returns items with the attribute Make that contain the value Audi and the attribute Model that contain the value S4.
To view the attributes of the returned items, see Getting the Attributes of an Item.
To run the sample
Open AmazonSimpleDBSamples.vb.
Comment out the code you added in the previous section.
Add the following to the Query Action section:
Dim multiAttributeQueryAction As New Query()
multiAttributeQueryAction.WithDomainName("MyStore").WithQueryExpression("['Make' = 'Audi'] intersection ['Model' = 'S4']")
QuerySample.InvokeQuery(service, multiAttributeQueryAction)
Run the sample.
Amazon SimpleDB returns items with the attribute Make that contain the value Audi and the attribute Model that contain the value S4.
To view the attributes of the returned items, see Getting the Attributes of an Item.
To run the sample
Open the scratchpad application with a web browser.
Select Query from the Explore API list box.
Enter MyStore in the Domain Name field.
Enter the following in the Query Expression field: ['Make' = 'Audi'] intersection ['Model' = 'S4'].
To limit the number of items returned, enter a value in the Max Number Of Items field.
If there are more items than you specified in the Max Number Of Items field, Amazon SimpleDB returns a next token.
If you need to view the next page of results, enter the next token in the Next Token field.
![]() | Note |
|---|---|
To get the next page of results, you only need to specify the domain name and the next token. |
Select from the following:
To invoke the request, click Invoke Request.
SDB; returns items with the attribute Make that contain the value Audi and the attribute Model that contain the value S4.
To view the signed URL, click Display Signed URL. Then, copy and paste the signed URL into a browser.
SDB; returns items with the attribute Make that contain the value Audi and the attribute Model that contain the value S4.
To view the string to sign, click Display String to Sign.
To view the attributes of the returned items, see Getting the Attributes of an Item.