Is there a way to do a MySQL query for data fields that start with but may not fully contain a given string?
For instance, if I had the following list of data items:
my_table
1. example.com
2. example.com/subpage
3. subdomain.example.com
4. ain.example.com
5. ple.com
I would like to feed
- “example.com/subpage” and return #1, #2
- “example.com” and return #1
- “wexample.com” and return nothing
- “exa” and return nothing
- “subdomain.example.com/subpage” and return #3
Thanks a lot!
Given:
Searching for “example.com/subpage” would require the following query:
Just don’t try to run it over a large dataset frequently…
Docs: http://dev.mysql.com/doc/refman/5.0/en/string-functions.html#function_instr