0% found this document useful (0 votes)
11 views3 pages

Program 6

The document outlines a program demonstrating SQL pattern matching using the 'LIKE' command with both percentage and underscore methods. It provides examples of queries to select names from a 'bca' table based on specific patterns. Additionally, it includes instructions for using the 'ORDER BY' command to sort results in ascending and descending order.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
11 views3 pages

Program 6

The document outlines a program demonstrating SQL pattern matching using the 'LIKE' command with both percentage and underscore methods. It provides examples of queries to select names from a 'bca' table based on specific patterns. Additionally, it includes instructions for using the 'ORDER BY' command to sort results in ascending and descending order.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd

Program 6

Write a program to show pattern matching and order by command.


1. Using like with percentage method:
 mysql> select * from bca where name like "s%";

 mysql> select * from bca where name like "%h%";

 mysql> select * from bca where name like "%i";


2. Using like with underscore method:

 mysql> select * from bca where name like "s_ _ _ _";

 mysql> select * from bca where name like "__h__";

 mysql> select * from bca where name like "__h__d__";


3. Using like with both percentage and underscore:
 mysql> select * from bca where name like "__h%";

Order by command
1. Ascending:
 mysql> select * from bca
-> order by name asc;

2. Descending:
mysql> select * from bca
-> order by name desc;

You might also like