With a table table1 with columns like:
name, dept, col1, col2, col3, col4, col5
I need to find rows with same values across multiple columns - e.g. col2, col3, col4, col5
While something like below would work, I need an approach that would work even for large number of columns, without having to have the multiple and conditions.
select *
from table1
where col2 = col3 and col3 = col4 and col4 = col5
ALLor generating sql is the simple solution. See my answer for examples.