Get the Values from the Any Combination of a Record from Table

This tutorial about how to get the values from the any combination of a record from table.

data 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.

  1. select * from table where material_name like 'p%'  
sql table

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'
  1. select * from table where material_name like 'p__t'(Note: here 2 underscores)   
material table

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'


Sql table of material

I hope this tutorial is useful.