How to use LIKE clause in query function

前端 未结 3 1391
感情败类
感情败类 2021-01-05 11:37

I am making an application which search messages in the inbox based on sender number. Here is my code:

public void onClick(View v)
{
    Toast.makeText(this,         


        
3条回答
  •  陌清茗
    陌清茗 (楼主)
    2021-01-05 12:00

    There is two joker : "%" and "_".

    "%" is replacing any string (multiple characters),

    "_" is replacing one (and only one) character.

    For example :

    LIKE 'B%' 
    

    let you find everything which starts with "B". (like "BATMAN");

    LIKE '%B%'
    

    let you find everthing which contains "B". (like "ABBA");

    LIKE'_B%'
    

    let you find everything which contains ONE caracter, then a "B". (like "ABERCROMBIE)".

    if you want to retrieve a string which contains "%" or "_", you may use an escape caracter :

    LIKE '%#_B%' ESCAPE #
    

    let you find any strings which contains one "_" followed by a "B". (like "TEST_BATMAN").

    I hope that helped.

    Al_th

提交回复
热议问题