查询多个值 [英] Querying multiple values
本文介绍了查询多个值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在尝试按多个值进行过滤,但是我似乎无法使and子句起作用(例如filter1和filter 2 ...等):
I'm trying to filter by multiple values however I can't seem to get an and clause to work (e.g. filter1 and filter 2 ... etc.):
显示数据库名称为"testing"的快照
Show me snapshots where the database name is '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"的快照
Show me snapshots named '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的数据库测试快照
Show me snapshots from the database testing that are named test1
aws rds describe-db-snapshots --include-shared --query 'DBSnapshots[?DBInstanceIdentifier==`testing`][?DBSnapshotIdentifier==`test1`].{DBNAME:DBInstanceIdentifier,SNAPSHOT:DBSnapshotIdentifier}'
[]
如何实现?
推荐答案
您需要使用 AND
表达式,所以像这样的窍门
You need to work with the AND
expression so something like this will make the trick
$ aws rds describe-db-snapshots --include-shared \
--query 'DBSnapshots[?(DBInstanceIdentifier==`testing` && DBSnapshotIdentifier==`test1`)].{DBNAME:DBInstanceIdentifier,SNAPSHOT:DBSnapshotIdentifier}'
这篇关于查询多个值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文