This tutorial about how to get the values from the any combination of a record from table.
- SQL have the wonderful feature LIKE.
- LIKE is keyword for following of WHERE condition.
- LIKE supports %,_ operators.
Lets we look demo,
Like with %
The following query gives the output which are the material_name starts with p. '%' operator supports multi character. so p% means all the values starts with p.
- select * from table where material_name like 'p%'
Like with _
The following query gives the output for which are the material name starts with 'p' and following 2 characters and end with 't'
- select * from table where material_name like 'p__t'(Note: here 2 underscores)
Another example with % and _
We already discussed with % represents multi character pattern and _ represents one character, use this functionality we can play some thing.
The following query gives, starts with 'p' and multi characters and one space and 3 characters and finally ends with 't'
select * from table where material_name like 'p% ___t'
I hope this tutorial is useful.