I have a table that features 20 columns, the results of these are either y, n or na.
The vast majority of the results are y so a typical row would be
id | col1 | col2 | col3 | col4 | col5 | col6 etc (the actual comumn names are not sequential, I just did this for ease)
123 | y | y | y | n | y | y
I have been asked to output which columns have a n, so in my example above I need to echo
"There is 1 answer of NO, the row with NO is
col4"
another example
456 | y | n | y | n | y | y
"There are 2 answers of NO, the rows with NO is
col2
col4"
Now my initial thought would be to use an if statement on each column and build up a string to output but is there an easier way?
The vast majority of the results are y so a typical row would be
id | col1 | col2 | col3 | col4 | col5 | col6 etc (the actual comumn names are not sequential, I just did this for ease)
123 | y | y | y | n | y | y
I have been asked to output which columns have a n, so in my example above I need to echo
"There is 1 answer of NO, the row with NO is
col4"
another example
456 | y | n | y | n | y | y
"There are 2 answers of NO, the rows with NO is
col2
col4"
Now my initial thought would be to use an if statement on each column and build up a string to output but is there an easier way?