SQL command based on PHP strstr or LIKE

后端 未结 1 1053
被撕碎了的回忆
被撕碎了的回忆 2021-01-20 16:58

Could somebody please offer some assistance. I have a standard SQL command as follows

$SQL = \"SELECT * FROM table WHERE Date > :FromDate AND Date < :E         


        
相关标签:
1条回答
  • 2021-01-20 17:25

    You're using strstr in the same manner as substr, where the string contains ABC.

    SELECT *
        FROM table
        WHERE Date > :FromDate
        AND Date < :EndDate
        AND col1 LIKE '%$string%';
    

    If you want to search for a string where the first characters are ABC, use:

    SELECT *
        FROM table
        WHERE Date > :FromDate
        AND Date < :EndDate
        AND col1 LIKE '$string%';
    

    stristr, however, would be a different story altogether.

    0 讨论(0)
提交回复
热议问题