有5个搜索条件,如性别(1),出生年月(2),联系方式(3),工作地点(4),职位(5)那么理论上来说就有5的阶乘个搜索组合,是不是就要写5的阶乘个搜索select语句???那不是太过分了..........

解决方案 »

  1.   

    可以这样阿
    String strSQL = "Select * From Table Where (1=1) ";
    if(按性别搜)
       strSQL += "And (Sex = " + sex的值 + ") ";  其它同理
      

  2.   

    首先判断五个条件是否有值,如果没有值,就使用 like '*'
    if(strname == "")
    {
        string strname = "like '*'"
    }
    else
    {
       string strname = "like 'name%'"}
    string strSql = "select * from Table where (name" + strname +  ") and () and () and () and ()";
      

  3.   

    LaoDai_Net(老代.Net『学无止境』) 可以