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
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
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
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
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!