AWS SimpleDB 选择表达式 iPhone

发布于 2024-12-05 14:36:40 字数 945 浏览 2 评论 0原文

我需要为 SimpleDB 构造一个 selectExpression,其中我只想要属性 = 到 X 的项目,按属性 Y 降序排序。到目前为止我所拥有的就是:

NSString *selectExpression = [NSString stringWithFormat:@"select itemName() from `%@`",domainString];

@try {
    SimpleDBSelectRequest  *selectRequest2  = [[[SimpleDBSelectRequest alloc] initWithSelectExpression:selectExpression] autorelease];
    SimpleDBSelectResponse *selectResponse = [[Constants sdb] select:selectRequest2];

    if (items == nil) {
        items = [[NSMutableArray alloc] initWithCapacity:[selectResponse.items count]];
    }
    else {
        [items removeAllObjects];
    }
    for (SimpleDBItem *item in selectResponse.items) {
        [items addObject:item.name];
    }
    [items sortUsingSelector:@selector(compare:)];
}
@catch (AmazonServiceException *exception) {
    NSLog(@"Exception = %@", exception);
}

我宁愿只选择属性 X by Y 的项目(上面)而不是获取所有项目然后排序。我该如何添加这个?它是放在 selectExpression 字符串中还是其他地方。非常感谢!

I need to construct a selectExpression for SimpleDB where I only want items with attributes = to X, sorted in descending order by attribute Y. All I have so far is this:

NSString *selectExpression = [NSString stringWithFormat:@"select itemName() from `%@`",domainString];

@try {
    SimpleDBSelectRequest  *selectRequest2  = [[[SimpleDBSelectRequest alloc] initWithSelectExpression:selectExpression] autorelease];
    SimpleDBSelectResponse *selectResponse = [[Constants sdb] select:selectRequest2];

    if (items == nil) {
        items = [[NSMutableArray alloc] initWithCapacity:[selectResponse.items count]];
    }
    else {
        [items removeAllObjects];
    }
    for (SimpleDBItem *item in selectResponse.items) {
        [items addObject:item.name];
    }
    [items sortUsingSelector:@selector(compare:)];
}
@catch (AmazonServiceException *exception) {
    NSLog(@"Exception = %@", exception);
}

I would prefer to only select items (above) with attributes X by Y rather than get all items and then sort. How do I add this? Does it go in the selectExpression string or somewhere else. Many thanks!

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

你丑哭了我 2024-12-12 14:36:40

试试这个——

Select x,y from <domain_name> where itemName() is not null order by itemName() asc 

Try this out --

Select x,y from <domain_name> where itemName() is not null order by itemName() asc 
调妓 2024-12-12 14:36:40
NSString *selectExpression = [NSString stringWithFormat:@"select itemName() from `%@` where X = '%@' order by 'X' descending",domainName,attributeValue];
NSString *selectExpression = [NSString stringWithFormat:@"select itemName() from `%@` where X = '%@' order by 'X' descending",domainName,attributeValue];
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文