Given a table of measurements as strings (i.e. "4.6 Inches, 3mm", "Length: 4.66in", etc), I'd like to retrieve rows with essentially anything left or right of the number, so long as the number matches.
In other words, if I'm searching for "6":
- match: "6 in", "6in", "asdf 6 in", etc
- don't match: "16 in", "6.6 in", "with 66 in", etc
I have the following query thus far:
select distinct length from items where length ~ '[[:<:]]6[[:>:]]';
But it's not quite what I'm looking for, as this is the result:
length
---------------
6.25 Inches
4.6666 Inches
6.5 Inches
1.66 Inches
6 Inches
6.75 Inches
6.71 Inches
24.6 Inches
3.6666 Inches
I'm using PostgreSQL 9. Any help would be appreciated. Thanks