This tutorial about how to get the values from the any combination of a record from table.
1.SQL have the wonderful feature LIKE.
2.LIKE is keyword for following of WHERE condition.
3.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.
No comments :
Post a Comment