Home > Mobile >  filter table rows based on a value by having other value at the same row
filter table rows based on a value by having other value at the same row

Time:09-17

i have those objects coming from model through controller:

{value: "#cfcfcf", option_id: "11", item_id: "25", var_id: "70"}
 {value: "64GB", option_id: "12", item_id: "25", var_id: "70"}
 {value: "#e8baba", option_id: "11", item_id: "25", var_id: "71"}
 {value: "64GB", option_id: "12", item_id: "25", var_id: "71"}

i want to write a query where i only get the row with the same var_id, knowing the value of just one row of them i want the other one, for example, i have the value "#cfcfcf" which is unique in the table, and at the same row it has var_id which is 70, so based on that value i want the other row that has the same var_id, how can accomplish that with codeigniter query builder

CodePudding user response:

Make another function model and join the 3 tables together again to return var_id, then pass var_id to the other function model which filters the result based on it.

  • Related