Q:

Reverse wildcard query in mysql (Can the wildcard reside in database?)

Sorry for the unclear title.  Let me explain what I am asking with an example.
URI table below
id   |   uri     
---------------
1    | /admin%
2    | /cart%
3    | /account%

What I want is, if I am on the page /cart/checkout/index.php to be able to query the database and get id=2.  Similarly if I am in /admin/edit.php?id=123 I use that value to query the database and get id=1
How I think of it as a reverse wildcard query...the wildcard resides in the database not the query.
If this possible I would appreciate any help getting this to work

A:

Yes.  It would work just as you would expect:
select ut.*
from URITable ut
where @MYURL like ut.URIPattern;

This cannot take advantage of indexes, so it will be doing a sequential scan.  That should be fine if the table only has a few patterns.  If you are planning on doing this with thousands of patterns, performance might be an issue.

