Advertise Mobile SDKs Books Events Forum News Social Networking Support Us
Follow @iphonedevsdk on Twitter

Interface 2, Advanced iOS
Mockup & Code Gen
($9.99)

Make your own iPhone apps
and run them live!
(free)

Pic Frame Dynamo: Photo Editing
($0.99)

Abiliator
($1.99)

Want your application or service advertised on iPhone Dev SDK?

Go Back   iPhone Dev SDK Forum > iPhone SDK Development Forums > iPhone SDK Development

Reply
 
LinkBack Thread Tools Display Modes
Old 09-14-2010, 11:15 PM   #1 (permalink)
Registered Member
 
Join Date: Sep 2010
Posts: 6
riseteck is on a distinguished road
Question Complex sqlite querry

Hello,
I'm new to playing with sqlite.
The querry I need into the created database is going to be very complex.
Table contains Three values to extract by Green/Wind/Distance

Select * from Table1 Where Green = data picker green selection AND wind=datapicker wind selection AND Distance <= datapicker distance selection AND Distance +10 >= datapicker distance selection

Table contains green/wind/distance and the querry should output all selected data within those parameters. Distance selection should within a range of 10 (lower) from the datapicker distance selection. Setting up a normal select looks pretty simple. Famous last words... I don't know how to incorperate the datapicker text values into the querry.
Instead of pounding my head into the wall and trying all sorts of nonsense before I get it right I'll ask first.
Thanks!
Roger
riseteck is offline   Reply With Quote
Old 09-15-2010, 01:39 AM   #2 (permalink)
Registered Member
 
kelvinkao's Avatar
 
Join Date: Jul 2009
Location: Los Angeles
Posts: 352
kelvinkao is on a distinguished road
Send a message via AIM to kelvinkao
Default

I don't know what you mean by data picker. I assume you meant UIPickerView.

In that case, you can use selectedRowInComponent: to see which one is selected, and you can get the value of that from your data source.
__________________
My dev blog:
http://www.kelvinkaodev.com
kelvinkao is offline   Reply With Quote
Old 09-15-2010, 11:52 AM   #3 (permalink)
Registered Member
 
Join Date: Sep 2010
Posts: 6
riseteck is on a distinguished road
Talking

Quote:
Originally Posted by kelvinkao View Post
I don't know what you mean by data picker. I assume you meant UIPickerView.

In that case, you can use selectedRowInComponent: to see which one is selected, and you can get the value of that from your data source.

Kelvin, I should have used the UIpicker view as the value. That I can get quite easily. Sometimes things work the way you expect. The problem i'm hainv is finding a way to insert the changed values I want to search with into the SQL statement. The sql statement is set up as a long text string.
@"SELECT * from table1 WHERE green=low"
I want to insert a variable value in so I can use the same expression to search for Green low/level or elevated without writing a new sql statement for every variant.
I need a way to insert a variable into the text entry.
I have tried @"SELECT * from table1 WHERE green="[greens objectatIndex:i]
greens data comes from a array. I am hoping there is a way to insert the values of the object into the SQl statement. That will make my application possible. Without it I'llhave to use a large arrary or write up a series of sql statments to get it done.
Darn this was supposted to be the easy way to get it done!
Thanks
Getting closer with every answer
riseteck is offline   Reply With Quote
Old 09-15-2010, 02:07 PM   #4 (permalink)
Registered Member
 
kelvinkao's Avatar
 
Join Date: Jul 2009
Location: Los Angeles
Posts: 352
kelvinkao is on a distinguished road
Send a message via AIM to kelvinkao
Default

Oh, that's easy. You should read the NSString documentation about string manipulation.

For example, you can do this:
Code:
NSString* queryStr = [NSString stringWithFormat:@"SELECT * from table1 WHERE green=\"%@\"], [greens objectatIndex:i]];
__________________
My dev blog:
http://www.kelvinkaodev.com
kelvinkao is offline   Reply With Quote
Old 09-15-2010, 08:02 PM   #5 (permalink)
Registered Member
 
Join Date: Sep 2010
Posts: 6
riseteck is on a distinguished road
Thumbs up

Quote:
Originally Posted by kelvinkao View Post
Oh, that's easy. You should read the NSString documentation about string manipulation.

For example, you can do this:
Code:
NSString* queryStr = [NSString stringWithFormat:@"SELECT * from table1 WHERE green=\"%@\"], [greens objectatIndex:i]];
Got the quote working with NSString *qsql = [NSString stringWithFormat:
@"SELECT club,swing,airDistance,rollDistance,totalDistance FROM clubData WHERE green="@" AND wind="@" AND totalDistance =<"@"",
[animalSounds objectAtIndex:selectedSound],[windSpeed objectAtIndex:selectedWind],[animalNames objectAtIndex:selectedAnimal]
,[animalNames objectAtIndex:selectedAnimal]];
I tried using the / and % but it didn't seem to like that. Now to get the extracted data into a table and extract that table output to the screen.
Thanks I would have trying to figure that out for a month without coming up with that linkage.
My first programming experience was at the machine language level ages ago. So going I've gone from Basic to OO. I haven't had enough time with OO to learn all the ins and outs. But after I get the querry and output done I'm 85% done with my first Iphone app!
Only took 2 months to get here.
My blog Internet Marketing in Mundelein
riseteck is offline   Reply With Quote
Old 09-16-2010, 05:33 PM   #6 (permalink)
Registered Member
 
Join Date: Sep 2010
Posts: 6
riseteck is on a distinguished road
Question

Quote:
Originally Posted by riseteck View Post
Got the quote working with NSString *qsql = [NSString stringWithFormat:
@"SELECT club,swing,airDistance,rollDistance,totalDistance FROM clubData WHERE green="@" AND wind="@" AND totalDistance =<"@"",
[animalSounds objectAtIndex:selectedSound],[windSpeed objectAtIndex:selectedWind],[animalNames objectAtIndex:selectedAnimal]
,[animalNames objectAtIndex:selectedAnimal]];
I tried using the / and % but it didn't seem to like that. Now to get the extracted data into a table and extract that table output to the screen.
Thanks I would have trying to figure that out for a month without coming up with that linkage.
My first programming experience was at the machine language level ages ago. So going I've gone from Basic to OO. I haven't had enough time with OO to learn all the ins and outs. But after I get the querry and output done I'm 85% done with my first Iphone app!
Only took 2 months to get here.
My blog Internet Marketing in Mundelein
Next question:
1) What is a standard output for the SQL querry? The online info states it can be modified but what is the standard output?
2) When extracting data from a table how do you put the extracted data into a new table in a Iphone environment?
Still struggling along.
www.riseteck.com

Last edited by riseteck; 09-16-2010 at 05:35 PM. Reason: Missed data
riseteck is offline   Reply With Quote
Old 09-17-2010, 07:32 PM   #7 (permalink)
Registered Member
 
Join Date: Sep 2010
Posts: 6
riseteck is on a distinguished road
Question

Quote:
Originally Posted by riseteck View Post
Next question:
1) What is a standard output for the SQL querry? The online info states it can be modified but what is the standard output?
2) When extracting data from a table how do you put the extracted data into a new table in a Iphone environment?
Still struggling along.
Internet Marketing in Mundelein
OK the problem continues.
If I use NSString *level =@"elevated"; it works
I had NSString *level = rollerGreenSelected.text; It was working for a while and then it quit. The values were changing as I moved the UIPicker.
I am passing the string into my SQL statement
NSString *qsql =[NSString stringWithFormat: @"SELECT * FROM clubData where green ='%@'",level];

I need to get the value from the animalSounds ObjectAtIndex:SelectedSound into the *level value. The problem is the SelectedSound value is defined in another code segment so selectedSound shows up as undefined.
NSString *level = [NSString stringWithFormat:"%@", animalSounds objectAtIndex:selectedSound];
There must be a simple way I am not getting.
Any help appreciated!
riseteck is offline   Reply With Quote
Old 02-11-2011, 12:20 AM   #8 (permalink)
Registered Member
 
Join Date: Oct 2010
Posts: 28
rafiq is on a distinguished road
Default can we insert values to uipickerview from sqlite database table

Hi,
Can we insert values to uipickerview from database.If we can cen any one guide me by sending sample.

Thank u
rafiq is offline   Reply With Quote
Reply

Bookmarks

Tags
complex, select, sqlite

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



» Advertisements
» Online Users: 323
19 members and 304 guests
2ndSegment, bignoggins, cayladv57, cgokey, dermotos, djohnson, Domele, guusleijsten, Hamad, heshiming, linkmx, markuschow, Objective Zero, pungs, Rudy, Sloshmonster, teebee74, v1n2e7t
Most users ever online was 1,387, 04-10-2012 at 04:21 AM.
» Stats
Members: 175,655
Threads: 94,116
Posts: 402,889
Top Poster: BrianSlick (7,990)
Welcome to our newest member, pungs
Powered by vBadvanced CMPS v3.1.0

All times are GMT -5. The time now is 10:52 PM.
Powered by vBulletin® Version 3.8.0
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.3.0