I have a table with the following structure
id(int) | col1(int) | col2(int) | col3(int) ------------------------------------------ 1 | NULL | 10 | 20 2 | 5 | NULL | 30 3 | 8 | NULL | NULL
Given an 'id' value I need to find the minimum non-null value across all the columns in that record.
Like for example, for id=1, the value is 10. For id =2 the value is 5 and so on.
How do I do this in MySQL?
Any help would be greatly appreciated!