我读了这份文件 http://docs.aws.amazon.com/amazondynamodb/latest/APIReference/API_Condition.html
也许RDB的条件等效not in
只存在in
条件。
如何实施not in
或是否相当于not in
?
答案 0 :(得分:5)
这是PHP中的实现
public function getRecordsByInExpression($tableName, $providerCode, $fieldName, $values, $logicalOp = self::IN_EXP)
{
$queryExp =[
'TableName' => $tableName,
'KeyConditionExpression' => 'ProviderCode = :pc',
'FilterExpression' => $logicalOp == self::IN_EXP ? "$fieldName IN (:list)" : "NOT ($fieldName IN (:list))",
'ExpressionAttributeValues' => [
':pc' => $providerCode,
':list' => implode(',', $values)
]
];
return $this->query($queryExp)->get('Items');
}
最后一个NOT IN = NOT(字段IN(:list))