Pattern match: string begin and end : Begin With « Regular Expression « SQL / MySQL

Home
SQL / MySQL
1.Aggregate Functions
2.Backup Load
3.Command MySQL
4.Cursor
5.Data Type
6.Database
7.Date Time
8.Engine
9.Event
10.Flow Control
11.FullText Search
12.Function
13.Geometric
14.I18N
15.Insert Delete Update
16.Join
17.Key
18.Math
19.Procedure Function
20.Regular Expression
21.Select Clause
22.String
23.Table Index
24.Transaction
25.Trigger
26.User Permission
27.View
28.Where Clause
29.XML
SQL / MySQL » Regular Expression » Begin With 
Pattern match: string begin and end
    
Drop table employee;

CREATE TABLE employee (
    id int unsigned not null auto_increment primary key,
    firstname varchar(20),
    lastname varchar(20),
    title varchar(30),
    age int,
    yearofservice int,
    salary int,
    perks int,
    email varchar(60)
)



INSERT INTO employee (firstname, lastName, title, age, yearofservice, salary, perks, emailvalues ("John""Chen""Senior Programmer"31312000025000"[email protected]");

INSERT INTO employee (firstname, lastName, title, age, yearofservice, salary, perks, emailvalues ("Jan""Pillai""Senior Programmer"32411000020000"[email protected]");

INSERT INTO employee (firstname, lastName, title, age, yearofservice, salary, perks, emailvalues ("Ane""Pandit""Web Designer"2439000015000"[email protected]");

INSERT INTO employee (firstname, lastName, title, age, yearofservice, salary, perks, emailvalues ("Mary""Anchor""Web Designer"2728500015000"[email protected]");

INSERT INTO employee (firstname, lastName, title, age, yearofservice, salary, perks, emailvalues ("Fred""King""Programmer"3237500015000"[email protected]");
INSERT INTO employee (firstname, lastName, title, age, yearofservice, salary, perks, emailvalues ("John""Mac""Programmer"3248000016000"[email protected]");
INSERT INTO employee (firstname, lastName, title, age, yearofservice, salary, perks, emailvalues ("Arthur""Sam""Programmer"2827500014000"[email protected]");
INSERT INTO employee (firstname, lastName, title, age, yearofservice, salary, perks, emailvalues ("Alok""Nanda""Programmer"3237000010000"[email protected]");
INSERT INTO employee (firstname, lastName, title, age, yearofservice, salary, perks, emailvalues ("Susan""Ra""Multimedia Programmer"3249000015000"[email protected]");
INSERT INTO employee (firstname, lastName, title, age, yearofservice, salary, perks, emailvalues ("Paul""Simon""Multimedia Programmer"2318500012000"[email protected]");
INSERT INTO employee (firstname, lastName, title, age, yearofservice, salary, perks, emailvalues ("Edward""Parhar""Multimedia Programmer"3027500015000"[email protected]");
INSERT INTO employee (firstname, lastName, title, age, yearofservice, salary, perks, emailvalues ("Kim""Hunter""Senior Web Designer"32411000020000"[email protected]");
INSERT INTO employee (firstname, lastName, title, age, yearofservice, salary, perks, emailvalues ("Roger""Lewis""System Administrator"32310000013000"[email protected]");
INSERT INTO employee (firstname, lastName, title, age, yearofservice, salary, perks, emailvalues ("Danny""Gibson""System Administrator"3129000012000"[email protected]");
INSERT INTO employee (firstname, lastName, title, age, yearofservice, salary, perks, emailvalues ("Mike""Harper""Senior Marketing Executive"36112000028000"[email protected]");
INSERT INTO employee (firstname, lastName, title, age, yearofservice, salary, perks, emailvalues ("Mary""Sunday""Marketing Executive"3159000025000"[email protected]");
INSERT INTO employee (firstname, lastName, title, age, yearofservice, salary, perks, emailvalues ("Jack""Sim""Marketing Executive"2717000018000"[email protected]");
INSERT INTO employee (firstname, lastName, title, age, yearofservice, salary, perks, emailvalues ("Joe""Irvine""Marketing Executive"2717200018000"[email protected]");
INSERT INTO employee (firstname, lastName, title, age, yearofservice, salary, perks, emailvalues ("Henry""Ali""Customer Service Manager"323700009000"[email protected]");
INSERT INTO employee (firstname, lastName, title, age, yearofservice, salary, perks, emailvalues ("Peter""Champion""Finance Manager"32212000025000"[email protected]");

select from employee;

SELECT lastName from employee where
lastName like 'S%' OR lastName like 'A%';

           
         
    
    
    
  
Related examples in the same category
1.The caret (^) anchors the start, and the dollar sign ($) the end;
2.Pattern Matching: beginning with 'b'
3.String begins with
4.Pattern match: string begin with a certain letter
5.Show records where the name begins with a "B"
6.Show records where the name begins with a "B" or "C"
7.Strings that begin with a particular substring:
8.Matches strings that begin with a vowel or end with er:
9.Matches where a is the first character
java2s.com  | Contact Us | Privacy Policy
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.