6

我正在尝试按多个值进行过滤,但是我似乎无法使 and 子句起作用(例如 filter1 和 filter 2 ...等):

显示数据库名称为“testing”的快照

aws rds describe-db-snapshots --include-shared --query 'DBSnapshots[?DBInstanceIdentifier==`testing`].{DBNAME:DBInstanceIdentifier,SNAPSHOT:DBSnapshotIdentifier}'
[
    {
        "SNAPSHOT": "test1",
        "DBNAME": "testing"
    },
    {
        "SNAPSHOT": "test2",
        "DBNAME": "testing"
    },
    {
        "SNAPSHOT": "test3",
        "DBNAME": "testing"
    },
    {
        "SNAPSHOT": "test4",
        "DBNAME": "testing"
    }
]

显示名为“test1”的快照

$ aws rds describe-db-snapshots --include-shared --query 'DBSnapshots[?DBSnapshotIdentifier==`test1`].{DBNAME:DBInstanceIdentifier,SNAPSHOT:DBSnapshotIdentifier}'
[
    {
        "SNAPSHOT": "test1",
        "DBNAME": "testing"
    },
        {
        "SNAPSHOT": "test1",
        "DBNAME": "testing2"
    }
]

显示来自名为 test1 的数据库测试的快照

aws rds describe-db-snapshots --include-shared --query 'DBSnapshots[?DBInstanceIdentifier==`testing`][?DBSnapshotIdentifier==`test1`].{DBNAME:DBInstanceIdentifier,SNAPSHOT:DBSnapshotIdentifier}'
[]

如何做到这一点?

4

1 回答 1

13

您需要使用AND表达式,所以这样的事情会成功

$ aws rds describe-db-snapshots --include-shared \
--query 'DBSnapshots[?(DBInstanceIdentifier==`testing` && DBSnapshotIdentifier==`test1`)].{DBNAME:DBInstanceIdentifier,SNAPSHOT:DBSnapshotIdentifier}'
于 2017-11-07T18:23:59.220 回答