I have a table named t,
focus, H, Li, Be, B, C
H, 1, 2, 3, 4, 5
Be, 6, 7, 8, 9, 10
I want to write a MySQL query to select columns in this table based on the values of focus
column, for example, from table t it will return:
H, Be
1, 3
6, 8
I know it's very easy to write:
select H, Be from t
However, this is not a dynamic resolution if the content of table t changed. For example, assuming table t now is:
focus, H, Li, Be, B, C
B, 5, 0, 0, 4, 4
C, 8, 9, 1, 7, 3
Previous code doesn't work. It still returns the same result instead of:
B, C
4, 4
7, 3
My question is, is it possible, we wrote a MySQL script to select the columns based on the values of focus
column?