http://www.technicalpage.net/search/label/SQL

LikeInSQL

 "Like with %" , this is used to search the data from table with incomplete column name.

For example:

Name Dept Salary comm State
Ram Technical 1000 null TX
Sam Admin 1100 null CA
Hari Mechanical 1200 null TX
Raju Helper 800 800 TX
Govind HR 1000 null CA
Murali Driver 900 null NY
Murali1 DHead null null NY
SitaActor1400111TX

1.    

1.  1.  select * from TableUnitTest where name like  '%nd';

Name    Dept      Salary    comm    State

Govind  HR          1000      null         CA

 

2.   2.    select * from TableUnitTest where name like  'nd%';

No result.

 

3.    3.  select * from TableUnitTest where name like  '%nd%';

Name    Dept      Salary    comm    State

Govind  HR          1000      null         CA

 

4.    4.    select * from TableUnitTest where name like  'R%';

Name      Dept          Salary    comm    State

Ram       Technical    1000      null         TX

Raju       Helper         800        800        TX

 

5.     5.  select * from TableUnitTest where name like  '%R%';

Name      Dept                  Salary    comm    State

Ram       Technical             1000      null         TX

Hari        Mechanical         1200      null         TX

Raju        Helper                 800        800        TX

Murali     Driver                 900        null         NY

Murali1   DHead                null         null         NY

 

6.      6. select * from TableUnitTest where salary like  '%2%' ;

Name      Dept                   Salary    comm    State

Hari        Mechanical         1200      null         TX



No comments:

Post a Comment