для UIPickerView с двумя компонентами см. По ссылке http://www.iphonetut.com/iphone_apps_-_interface_builder/86/uipickerview_with_two_component_example
это идеальный ответ на ваш запрос, вам нужно просто добавить свою функцию SQL в событие нажатия кнопки
-(IBAction)buttonPressed
{
NSString *msg = [NSString stringWithFormat: @"I am feeling %@ for the activity %@",
[names objectAtIndex:[pickerView selectedRowInComponent:0]],
[age objectAtIndex:[pickerView selectedRowInComponent:1]]];
NSLog(@"%@,%@",[nameArray objectAtIndex:[pickerView selectedRowInComponent:0]],[ageArray objectAtIndex:[pickerView selectedRowInComponent:1]]);
sqlite3 *database;
NSMutableArray *Favorite=[[NSMutableArray alloc] init];
if(sqlite3_open([dbPath UTF8String], &database) == SQLITE_OK) {
NSLog(@"Open");
NSString *sql=[NSString stringWithFormat:@"SELECT * FROM thirdTable WHERE name='%@' AND age='%@'", [nameArray objectAtIndex:[pickerView selectedRowInComponent:0]], [ageArray objectAtIndex:[pickerView selectedRowInComponent:1]]];
NSLog(@"sqlTm p %@", sqlTmp);
const char *sqlStmt=[sqlTmp UTF8String];
sqlite3_stmt *cmp_sqlStmt;
if(sqlite3_prepare_v2(database, sqlStmt, -1, &cmp_sqlStmt, NULL) == SQLITE_OK) {
NSLog(@"prepare stmt ");
while(sqlite3_step(cmp_sqlStmt)==SQLITE_ROW) {
NSString *a1=[NSString stringWithUTF8String:(char *)sqlite3_column_text(cmp_sqlStmt, 0)];
NSMutableDictionary *Question=[NSDictionary dictionaryWithObjectsAndKeys:
a1,@"detail",nil];
[Favorite addObject:Question];
}
}
sqlite3_finalize(cmp_sqlStmt);
sqlite3_close(database);
if(Favourite.count >0){
textView.text = [NSString stringWithFormat:@"%@", [Favorite objectAtImadex:0]];
}
[Favorite release];
}