Topic: [SQL Query] - Tip for boolean results
Hello all MVD fans,
A little tip for those of you who use script or SQL Search button to fill their tablegrids.
You might have noticed that boolean fields are recorded in database as Integer.
When you query such a field, the result will either be 1 (True) or 0 (False);
But I don't like having 1 and 0 in my tablegrids, I prefer True/false or even better, Yes/No.
Instead of querying the boolean field like :
SELECT
asset_name,
asset_owned
FROM assets
which will return 0 and 1, write your query like this :
SELECT
asset_name,
case
when asset_owned = 1 then 'Yes'
else 'No'
end AS asset_owned
FROM assets
Of course, you can do that with other fields than Boolean and transpose terms directly in your query.
Hope it helps
Cheers
Mathias
Each time I get a divorce, I keep the house
Zaza Gabor