Skip to content
Advertisement

filter the result by ‘g / ml’ using SQL

I have the below table from which I need to filter which holds both “g / ml”.

name            product
----------------------------------
Sunflower oil       pure 180g/200ml @Rs.20
groundnut oil       gold 300g @Rs.25
Olive oil       Filter 470g/500ml @Rs.30
coconut oil     Filter 1000ml @Rs.30

The below query gives me result as

select Name, product
from Logistic
where product like '%ml%'
name            product
----------------------------------
Sunflower oil       pure 180g/200ml @Rs.20
Olive oil       Filter 470g/500ml @Rs.30
coconut oil     Filter 1000ml @Rs.30

The expected result is

name            product
----------------------------------
Sunflower oil       pure 180g/200ml @Rs.20
Olive oil       Filter 470g/500ml @Rs.30

What I can apply in the where clause to get the expected results

Advertisement

Answer

Just use %g/%ml%. The % can appear in any position in the matching pattern.

User contributions licensed under: CC BY-SA
2 People found this is helpful
Advertisement