I want to get distinct values for a field, let say: field1…
This needs a query like: “select distinct(field1) from table”
However for some records, field1 is empty and there is another column that is an alternative to field1, which is field2. For the records where field1 is empty I need to use the value of field2. I think I need sort of a conditional select statement with if control something like:
select distinct( (if(field1!='') field1 else field2) ) from table
I have no idea on how to write it. Any help is appreciated…
This would work for both null and empty
field1.