Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to use join query in iOS using parse framework?

I have two tables:

1.) User:name,age,address-id

2.) Address: address-id,street-name,city,state

How can I get the list of users with address using JOIN query?

like

SELECT User.name, User.age, Address.street-name, Address.city, Address.state FROM User INNER JOIN Address ON:User.address-id=Address.address-id;

How can I get data from this two tables in one query?

like image 688
Vijay Hirpara Avatar asked Aug 04 '26 05:08

Vijay Hirpara


1 Answers

You cannot do a JOIN query directly, as the database backing parse.com is not a SQL database but a NoSQL database.

In your particular case, all you need to do is include the address in the user query:

PFQuery *query = [PFQuery queryWithClassName:@"User"];  // Or [PFUser query] if users are PFUsers
[query whereKey:@"someKey" equalTo:@"someValue"]; // Whatever you need to get a correct list of users
[query includeKey:@"address-id"];  // This includes all related Address objects in the result set
[query findObjects];  // Or preferably findObjectsInBackgroundWithBlock

This assumes that your address-id property is a relation or pointer.

like image 142
Marius Waldal Avatar answered Aug 06 '26 20:08

Marius Waldal



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!