Search code examples
mysqlsqlwhere-in

using farword slash in sql where condition


I'm trying to search an element which starts with / below is the query.

I've already tried...

Select id,url from myindex where url='[/]%' ;

Select id,url from myindex where url='/%';

but didn't work.
any suggestions to fix this?


Solution

  • You don't want =. You want like. The second is the way to go in MySQL:

    Select id, url
    from myindex
    where url like '/%';