I have a postcode column in my table with values like AB45*
, RD4*
, ADB567
etc.
Now I want to match my data with this column. The *
means that a string starting with AB45
should match with this column. If I use AB45 45D
it should fetch a row containing AB45*
If I use RD489
on my field, it should match with RD4*
column value.
What can I use to achieve this requirement?
Best Answer
db<>fiddle here
PS. REPLACE() converts the pattern to the format clear for LIKE (replaces the asterisk with the percent sign).