I have a problem I would like to know if I can tackle in my mysql query.
I have a list of “names” in my DB:
id=1, name="name1"
id=2, name="name11"
id=3, name="name111"
I would like to get the id of the name in db with the most common characters at the beginning.
=> name111someignorechar would return 3
=> name11someignorechar would return 2
=> name1someignorechar would return 1
Any idea?
If I use the LIKE keyword,
SELECT id FROM names WHERE CONCAT(name,”%”) LIKE “name111someignorechar”
It will return me 3 results !
Try this: