title: SQL select column if attribute is true
body: <p>I'm overthinking a lot about this, but what I'm trying to do is to select only the columns that is true from <code>object.attribute</code>.</p>
  
  <p>Scenario: I have one function java, inside of this function I have an <code>object</code> that has 50 <code>attribute</code> that has true or false. I'm trying to create a dynamic query that select only the columns if <code>object.attribute</code> is <code>true</code>. For example, <code>Person</code> is my object and has 50 attribute, <code>name, age, sex, wage</code> and so on. If <code>Person.name</code> is <code>true</code>, <code>Person.sex</code> is <code>true</code>, <code>Person.wage</code> is <code>false</code>, <code>Person.age</code> is <code>false</code>, select the <code>name</code> and <code>sex</code> column only.</p>
  
  <p>I tried to use <code>String sql = "...IF ELSE ..."</code> or <code>String sql = "...CASE WHEN..."</code> but I couldn't create the logic where the <code>true</code> come in, if do <code>column_name = object.attribute(true)</code>, will return null. Is it better to create a procedure? Or it can done in a query? How can I achieve this?</p>
  
  <p>If only shows name and sex, must appear "John", "31" as example</p>