sql多条件查询语句

如上图:三个文本可选项,那sql语句怎么写呢?

1、首先获取三个文本的值分别为Name,Age,Sex.

2、string sql="select * from 表 where 1=1";

3、if(Name!="")

{

sql=sql+"and userName like '%" + Name + "%'";

}

if(Age!="")

{

sql=sql+"and Age like '%" + Age + "%'";

}

if(Sex!="")

{

sql=sql+"and Sex like '%" +Sex + "%'";

}

相关文章:

  • 2022-12-23
  • 2022-02-28
  • 2022-12-23
  • 2022-12-23
  • 2022-02-12
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2021-06-03
  • 2022-12-23
  • 2021-11-24
  • 2022-12-23
  • 2022-12-23
相关资源
相似解决方案