If, for example, I had two fields such as ‘Dog’ and ‘Cat’ that defines whether a person has a dog or cat; and, they are bit types. And, I wanted to combine these fields for each person to say something like USER, ‘has a dog and a cat’ such as the following:-
SQL original —
select username, dog, cat from table
username dog cat
john 1 0
tim 1 1
SQL with combined –??
username petstatus
john 'has a dog but no cat'
tim 'has a dog and a cat'
Does anybody have any ideas on what would be the best way to achieve this type of functionality using SQL. Or, where can I get a copy of similar functionality.
Thanks,
Ric.
Try this :
UPDATE : For more than 2 columns dynamically, you need to set text as like readable sentence by this way :