I have two questions for java mysql
First, I have an array containing either 1 or 0.
If i want do to an if statement how can i then check if opt[0] = 1? is it like:
if (options[0] == 1
{
sqlBuilder.append("AND a.value1 = val[1]")
}
next question. I have another array containing different values, how can i use them in a mysql query.
Right now i got
StringBuilder sqlBuilder = new StringBuilder()
.append("SELECT * ")
.append("FROM `table1` a ")
.append("CROSS JOIN `table2` b ")
.append("CROSS JOIN ` table3` c ")
.append("CROSS JOIN `table4` d")
.append("WHERE c.`id` =" . val[0] );
So i need c.id = val[0]
)after the==1. Assuming thatoptions[]is anint[]..by+and you are fine."AND a.value1 = val[1]"actually be"AND a.value1 = '" + val[1] + "'"? And btw, this is quite vulnerable to SQL injection so please usePreparedStatements instead.intwithString; this is neither PHP nor Javascript.