Sunday, 20 November 2011



SQL LIKE operator used to searching for data in a database. LIKE Operator search for a specified pattern in a column.

Like Example (% wildcards)

1.)Example Statement:
Following SQL % wildcard S_Name can be start with 'J' from "Student_Details" table.
SQL> SELECT * FROM Student_Detail WHERE S_Name LIKE 'J%';
Example Result:

S_NoS_NameTotalPercentageAddressCity
1Jay50777.84BapunagarAhmedabad
4Jaimin46371.23ManinagarAhmedabad

2.)Example Statement:
The Percentage column starts with a digit 7.
SQL> SELECT * FROM Student_Detail WHERE Percentage LIKE '7%';
Example Result:

S_NoS_NameTotalPercentageAddressCity
1Jay50777.84BapunagarAhmedabad
2Ajay48774.92Modera Cross RoadMehsana
3Bhavesh46972.15Radhanpur Cross RoadMehsana
4Jaimin46371.23ManinagarAhmedabad

Like Example (_ wildcards)

Example Statement:
Following SQL _ wildcard S_Name can be any and after second character with 'a' from "Student_Details" table.
SQL> SELECT * FROM Student_Detail WHERE S_Name LIKE '_a%';
Example Result:

S_NoS_NameTotalPercentageAddressCity
1Jay50777.84BapunagarAhmedabad
4Jaimin46371.23ManinagarAhmedabad

Like Example ([charlist] wildcards)

1.)Example Statement:
Following SQL [charlist] wildcard S_Name can be started "A", "B", "D" in "Student_Detail" table.
SQL> SELECT * FROM Student_Detail WHERE S_Name LIKE '[ABD]%';
Example Result:

S_NoS_NameTotalPercentageAddressCity
2Ajay48774.92Modera Cross RoadMehsana
3Bhavesh46972.15Radhanpur Cross RoadMehsana
5Dolar42565.38PanchvatiAhmedabad

2.)Example Statement:
The Percentage column starts with a digit between 5 and 7 ([5-7])
SQL> SELECT * FROM Student_Detail WHERE Percentage LIKE '[5-7]_%';
Example Result:

S_NoS_NameTotalPercentageAddressCity
1Jay50777.84BapunagarAhmedabad
2Ajay48774.92Modera Cross RoadMehsana
3Bhavesh46972.15Radhanpur Cross RoadMehsana
4Jaimin46371.23ManinagarAhmedabad
5Dolar42565.38PanchvatiAhmedabad

Like Example ([^charlist] wildcards)

Example Statement:
Following SQL [^charlist] wildcard S_Name can be out of started "A", "B", "D" in "Student_Detail" table.
SQL> SELECT * FROM Student_Detail WHERE S_Name LIKE '[^ABD]%';
Example Result:

S_NoS_NameTotalPercentageAddressCity
1Jay50777.84BapunagarAhmedabad
4Jaimin46371.23ManinagarAhmedabad


SQL GUIDE

0 comments:

Post a Comment

TrainingHUB. Powered by Blogger.

Total Pageviews

THE BEST QTP TRAINING INSTITUTE IN HYDERABAD

QTP Training in hyderabad

Sql Tutorial

Popular Posts

Our Facebook Page

TrainingHUB

Followers