Skip to content Skip to sidebar Skip to footer

SQL Command Based On PHP Strstr Or LIKE

Could somebody please offer some assistance. I have a standard SQL command as follows $SQL = 'SELECT * FROM table WHERE Date > :FromDate AND Date < :EndDate'; This works fin

Solution 1:

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.


Post a Comment for "SQL Command Based On PHP Strstr Or LIKE"