Home > Back-end >  filter the result by 'g / ml' using SQL
filter the result by 'g / ml' using SQL

Time:12-17

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

CodePudding user response:

just to use %g/%ml%. the % can appear on any position in the matching pattern.

  •  Tags:  
  • sql
  • Related