java - MySql - How to query multiple boolean columns? -


i have 15 boolean columns in sql table. want query in efficient way withot using :

"bool1 = bool1val , bool2=bool2val , bool3=bool3val....." 

is there way better?

thanks lot

you can combine these columns single string column of 0's , 1's , read them @ single query 0011 means false false true true.

have char 16 store this. (just database optimisation)

    // courtesy @amitmahajan comment     string selecttablesql = "select user_flags dbuser";      statement statement = dbconnection.createstatement();      resultset rs = statement.executequery(selecttablesql);      while (rs.next())      {      string userflags = rs.getstring("user_flags”);      boolean isuserenabled = userflags.charat(0)==1?true:false;      }  

Comments

Popular posts from this blog

Fail to load namespace Spring Security http://www.springframework.org/security/tags -

sql - MySQL query optimization using coalesce -

unity3d - Unity local avoidance in user created world -