I am trying to loop through a table adl_weight that has a column with the exact names of a column from another table adl_activities. I am trying to grab the column name from the table and use that to grab the value of the column on the second table.
Is it possible to do this with mysql? I have tried to use prepared statements but so far these aren't working.
set i = 1;
select count(*) from adl_weight into n;
WHILE(i<n) DO
set tmp_condition =(select user_condition from adl_weight where row_number = i);
set tmp_score = (select tmp_condition from adl_activities where userid = id);
if(tmp_score > 0) then
#do items here
end if;
END WHILE;
JOIN, no?