如何在Parse.com中使用OR查询Objective-C库

时间:2022-04-18 05:46:51

I want to run following query in Parse.com Objective-C library for iOS and wondering how to do it.

我想在iOS的Parse.com Objective-C库中运行以下查询,并想知道如何做到这一点。

Select * From Table Where firstName = "" OR lastName = "";

How I can achieve this in Objective-C library?

我如何在Objective-C库中实现这一目标?

1 个解决方案

#1


3  

You can do by using orQueryWithSubqueries as :

您可以使用orQueryWithSubqueries作为:

PFQuery *Query1 = [PFQuery queryWithClassName:@"yourClassName"];
[Query1 whereKey:@"firstName" equalTo:@""];

PFQuery *Query2 = [PFQuery queryWithClassName:@"yourClassName"];
[sQuery2 whereKey:@"lastName" equalTo:@""];

NSArray *arrQuery = [[NSArray alloc]initWithObjects:Query1,Query2, nil];
PFQuery *mainQuery = [PFQuery orQueryWithSubqueries:arrQuery];

[mainQuery findObjectsInBackgroundWithBlock:^(NSArray *arrRes,NSError *error) {

    if (!error) {
        NSLog(@"All data is = %@",arrRes);
    } else {
        DisplayAlertWithTitle(@"Error",@"Unable to get record");
    }
}];

I think this will work for you.let me know if you any other question on parse.

我认为这对你有用。如果你有任何关于解析的问题,我知道。

#1


3  

You can do by using orQueryWithSubqueries as :

您可以使用orQueryWithSubqueries作为:

PFQuery *Query1 = [PFQuery queryWithClassName:@"yourClassName"];
[Query1 whereKey:@"firstName" equalTo:@""];

PFQuery *Query2 = [PFQuery queryWithClassName:@"yourClassName"];
[sQuery2 whereKey:@"lastName" equalTo:@""];

NSArray *arrQuery = [[NSArray alloc]initWithObjects:Query1,Query2, nil];
PFQuery *mainQuery = [PFQuery orQueryWithSubqueries:arrQuery];

[mainQuery findObjectsInBackgroundWithBlock:^(NSArray *arrRes,NSError *error) {

    if (!error) {
        NSLog(@"All data is = %@",arrRes);
    } else {
        DisplayAlertWithTitle(@"Error",@"Unable to get record");
    }
}];

I think this will work for you.let me know if you any other question on parse.

我认为这对你有用。如果你有任何关于解析的问题,我知道。