Comparison operators are applied to a single attribute and are lexicographical in nature. When designing an application, you should carefully think through storing data in its appropriate string representation. For more information, see Working with Numerical Data.
The following table shows all Amazon SimpleDB comparison operators.
Comparison Operator | Description | Select Example |
---|---|---|
= | Attribute value or itemName() equals the specified constant. |
|
!= | Attribute value or itemName() does not equal to the specified constant. |
|
> | Attribute value or itemName() is greater than the specified constant. | select * from mydomain where weight > '0034' |
>= | Attribute value or itemName() is greater than or equal to the specified constant. | select * from mydomain where weight >= '065' |
< | Attribute value or itemName() is less than the specified constant. | select * from mydomain where weight < '0034' |
<= | Attribute value or itemName() is less than or equal to the specified constant. | select * from mydomain where year <= '2000' |
like | Attribute value or itemName() contains the specified constant.
The Note
Using the To search for strings that contain the percent sign (%), you must escape it. For example, to search
for a string that ends in '3%', you enter |
select * from mydomain where author like 'Henry%'
select * from mydomain where keyword = 'Book' and author like '%Miller'
|
not like |
Attribute value or itemName() does not contain the specified constant.
The Note
Using the |
select * from mydomain where author not like 'Henry%'
select * from mydomain where keyword = 'Book' and author not like '%Miller'
|
between | Attribute value or itemName() falls within a range, including the start and end value. | select * from mydomain where year between '1998' and '2000' |
in | Attribute value or itemName() is equal to one of the specified constants. When used with items,
in acts as a batch get. |
select * from mydomain where year in('1998','2000','2003')
select * from mydomain where itemName() in('0385333498','0802131786','B000T9886K')
|
is null | Attribute does not exist. If an item has the attribute with an empty string, it is not returned.
NoteDue to performance issues, this operator is not recommended when most items have the specified attribute. |
select * from mydomain where year is null |
is not null | Attribute value or itemName() contains any value. | select * from mydomain where year is not null |
every() | For multi-valued attributes, every attribute value must satisfy the constraint.
NoteDue to the cost of running more complex queries, this operator is only recommended for multi-valued attributes. |
|