This is almost correct for you, but you do not understand the wildcard%.
In SQL, the% wildcard will match any string of any length. You want this in the beginning because you don't need the driving parts.
However, when you put it at the end of your LIKE matching string, it will allow a match if something happens after your string.
So let's take your example
ab123
XYZ123
pqc1238
Now, if the word is 123, it should return abc123 and xyz123, if c123, then return abc123 and> NOT pqc1238 and xyz123
if 238, then just return pqc1238 ....
You have% 123% you say: "I need all the lines that start with anything, then" 123 "and then end with anything." This will match any string that contains “123” at any point.
What you want to say is "I want all lines to start with anything, then" 123 "and then end." So this is% 123.
Finally, to get an EXACT match with a similar one, just leave all the wildcards away.
This page has a pretty good overview of SQL wildcards.
Herbn source share