c# mysql winfroms
需要判断100个查询条件 string str = " select * from clinMater where 1=1 ";if (comboBox1.Text.Trim() != "")
{
str += "and M2" + " = '" + comboBox1.Text + "'";
}
if (comboBox2.Text.Trim() != "")
{
str += "and M3" + " = '" + comboBox2.Text + "'";
}
以下判断100个查询条件,如果100个and条件都成立,sql语句能执行吗?
有没有简便效率的方法?
需要判断100个查询条件 string str = " select * from clinMater where 1=1 ";if (comboBox1.Text.Trim() != "")
{
str += "and M2" + " = '" + comboBox1.Text + "'";
}
if (comboBox2.Text.Trim() != "")
{
str += "and M3" + " = '" + comboBox2.Text + "'";
}
以下判断100个查询条件,如果100个and条件都成立,sql语句能执行吗?
有没有简便效率的方法?
可以运行,否则,生成数个临时表再连接起来
50-100个条件生成B2,都有相同的KEY字段,用连接就可以了,代码
就是累加字符串,生成WHERE 中的条件,你的就可以。