Using Pattern Matching LIKE '____ %' : LIKE « Query Select « Oracle PL/SQL Tutorial






SQL>
SQL> CREATE TABLE SAT (
  2     StudentID  INT NOT NULL,
  3     ExamID     INT NOT NULL,
  4     Mark       INT,
  5     IfPassed   SMALLINT,
  6     Comments   VARCHAR(255),
  7     CONSTRAINT PK_SAT PRIMARY KEY (StudentID, ExamID));

Table created.

SQL>
SQL>
SQL> INSERT INTO SAT (StudentID,ExamID,Mark,IfPassed,Comments) VALUES (1,1,55,1,'Satisfactory');

1 row created.

SQL> INSERT INTO SAT (StudentID,ExamID,Mark,IfPassed,Comments) VALUES (1,2,73,1,'Good result');

1 row created.

SQL> INSERT INTO SAT (StudentID,ExamID,Mark,IfPassed,Comments) VALUES (2,3,44,1,'Hard');

1 row created.

SQL> INSERT INTO SAT (StudentID,ExamID,Mark,IfPassed,Comments) VALUES (2,5,39,0,'Simple');

1 row created.

SQL>
SQL> SELECT Name FROM Student WHERE Name LIKE '____ %';



SQL>
SQL>
SQL> drop table SAT;

Table dropped.








2.19.LIKE
2.19.1.Using the LIKE Operator
2.19.2.Underscore character (_) matches one character in a specified position.
2.19.3.Percent character (%) matches any number of characters beginning at the specified position.
2.19.4.ESCAPE option
2.19.5.Combine UPPER and LIKE operator
2.19.6.Subquery with Like operator
2.19.7.Use _ and % together
2.19.8.Use three _ together
2.19.9.Use _ to match a phone number
2.19.10.Second letter is A
2.19.11.Using Pattern Matching LIKE '____ %'
2.19.12.ESCAPE from LIKE