search

Home  >  Q&A  >  body text

java - 如何解决where name like '%%' 当name 为null时,查询不到数据?

PHP中文网PHP中文网2802 days ago1811

reply all(12)I'll reply

  • 大家讲道理

    大家讲道理2017-04-18 10:46:56

    Why can’t we judge the two query variables before executing the SQL statement?

    The pseudo code is as follows:

    if (isNull(a)) {
        a = '';
    }
    
    if (isNull(b)) {
        b = '';
    }

    reply
    0
  • 阿神

    阿神2017-04-18 10:46:56

    From the perspective of efficiency, it is strongly recommended that when name or method is empty, the value will not be used as a query condition
    For example, if name is empty, it is directly
    where method like '%xxx%'

    reply
    0
  • Cancelreply