sqlite版本的vlookup(sqlite version of vlookup)
有没有办法在sqlite中做一个相当于vlookup的方法? 我正在尝试这样的事情:主表:ValueA | ValueB | concatValueA&VALUEB
映射表:concatValueA和ValueB | 映射值
决赛桌:ValueA | ValueB | concatValueA和ValueB | 映射值
在Excel中,我只是做一个vlookup。
有没有办法将映射值添加到sqlite中的表?
我试过这个:
UPDATE Master Set "mapped Value" = (select mapping."mapped Value" from Master left join mapping on Master.concat = mapping.concat)
但是这个填充将映射的Value列设置为完全等于select语句中的第一个值,但我希望这些值不同
is there a way in sqlite to do the equivalent of a vlookup? I'm trying to do something like this: Master table: ValueA | ValueB | concatValueA&ValueB
Mapping table: concatValueA&ValueB | mapped Value
final table: ValueA | ValueB | concatValueA&ValueB | mapped Value
In Excel, I would just do a vlookup.
Is there a way to add the mapped value to a table in sqlite?
I tried this:
UPDATE Master Set "mapped Value" = (select mapping."mapped Value" from Master left join mapping on Master.concat = mapping.concat)
But this fills sets the mapped Value column entirely equal to the first value from the select statement, but I would like the values to be different
原文:https://stackoverflow.com/questions/30109179
最满意答案
让我们假设你在
UITableViewController
中构建一个带有对象的数组(例如:MyObject.m / h)。 您应该使用didSelectRowAtIndexPath
检测用户选择了哪个单元格,然后在准备segue时使用该整数从数组中检索MyObject。 例如:- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{ cellPressed =(int)indexPath.row; //cellPressed is an integer variable(global variable in my VC [self performSegueWithIdentifier:@"toMyVC" sender:self]; }
现在准备ForSegue:
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender { if([[segue identifier] isEqualToString:@"toMyVc"]){ MyVC *mVC = [segue destinationViewController]; mVC.myObject = [myArrayWithMyObjects objectAtIndex:cellPressed]; } }
在您的编辑视图中:
IDEditVC *secondViewController = [storyBoard instantiateViewControllerWithIdentifier:@"editvc"]; secondViewController.myObj = myObjectRetrievedFromArray;
注意:您应该在.h文件中声明一个变量MyObject,以便从其他类可见。
在类中声明“全局”变量:
@interface ViewController : UIViewController{ int cellPressed; //This is accessible by any method in YourViewController.m }
Lets assume that in
UITableViewController
you are building the TableView an array with objects(eg: MyObject.m/h). You should detect which cell the user has select using thedidSelectRowAtIndexPath
and then retrieve MyObject from your array using that integer at prepare for segue. Eg:- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{ cellPressed =(int)indexPath.row; //cellPressed is an integer variable(global variable in my VC [self performSegueWithIdentifier:@"toMyVC" sender:self]; }
Now on prepareForSegue:
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender { if([[segue identifier] isEqualToString:@"toMyVc"]){ MyVC *mVC = [segue destinationViewController]; mVC.myObject = [myArrayWithMyObjects objectAtIndex:cellPressed]; } }
In your Edit View:
IDEditVC *secondViewController = [storyBoard instantiateViewControllerWithIdentifier:@"editvc"]; secondViewController.myObj = myObjectRetrievedFromArray;
Note: You should declare a variable MyObject in .h file in order to be visible from other classes.
Declaring a "global" variable in a class:
@interface ViewController : UIViewController{ int cellPressed; //This is accessible by any method in YourViewController.m }
相关问答
更多-
为什么不从viewController创建segue到Login和Profile View Controller并使用performSegueUsingIdentifier:并使用prepareForSegue:方法推送导航控制器 - (void)viewDidLoad { if(USER_IS_LOGGED_IN) { if(USER_PROFILE_COMPLETED) { [self sendRequest]; ...
-
在故事板中为你的UIViewController设置一个标识符。 然后使用我的标识符来实例化它: let storyboard = UIStoryboard(name: "MyStoryboardName", bundle: nil) let vc = storyboard.instantiateViewControllerWithIdentifier("someViewController") Set an identifier for your UIViewController in the stor ...
-
xcode / ios:以编程方式推送视图控制器并传递行信息(xcode/ios: push view controller programatically and pass row info)[2022-05-22]
让我们假设你在UITableViewController中构建一个带有对象的数组(例如:MyObject.m / h)。 您应该使用didSelectRowAtIndexPath检测用户选择了哪个单元格,然后在准备segue时使用该整数从数组中检索MyObject。 例如: - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{ cellPressed =(in ... -
最简单的方法是在模态VC上定义属性并为其分配索引路径。 - (void)editView:(id)sender { IDEditVC *secondViewController = (IDEditVC *)[self.storyboard instantiateViewControllerWithIdentifier:@"editvc"]; secondViewController.selectedIndexPath = yourIndexPath; } 其中selected ...
-
尝试按照答案中的步骤操作: https : //stackoverflow.com/a/9736559/2670912 。 由于您使用的是故事板,请尝试第一个选项。 在我看来,这是最容易使用的。 Try to follow the procedure in the answer: https://stackoverflow.com/a/9736559/2670912. Since you are using storyboards try the first option. In my opinion it ...
-
当我们解决每个问题时,我会更新这个答案。 如果您使用表视图作为选择的方法,那么您应该改为忽略表视图控制器而不是以模态方式推送新视图。 //In the table view controller's on cell selected method [self dismissViewControllerAnimated:YES completion:^{ //code }]; 推送视图将导致下一个视图置于顶部,如果您想从视图C返回查看A(假设您以模态方式呈现),您可以使用上面相同的代码从C返回到A ...
-
UIStoryboard *MainStoryboard = [UIStoryboard storyboardWithName:@"Main" bundle: nil]; InfoController *info=[MainStoryboard instantiateViewControllerWithIdentifier:@"InfoController"]; [self.navigation ...
-
这可能是以编程方式设置的Bug设置颜色 self.view.backgroundColor = [UIColor lightGrayColor]; This might be Bug set color programmatically by self.view.backgroundColor=[UIColor lightGrayColor];
-
在第二个控制器中创建NSString属性。 然后,在某些时候,使用像secondController.stringProperty = cellVal; 。 放置您发布的代码和分配的位置取决于您使用的是xib文件还是故事板。 在一种情况下,您可以在从笔尖初始化第二个控制器的位置执行此操作,否则您将在prepareForSegue中执行此操作:(使用seque中的目标控制器)。 Create a NSString property in your second controller. Then, at som ...
-
该错误是因为您指示目标viewController类是CollectionViewController,但CollectionViewController未实现businessName。 您应该指明实现businessName的自定义类,而不是CollectionViewController。 The error is because you are indicating that the destination viewController class is CollectionViewControlle ...