MySQL/Tutorials: Difference between revisions

From Citizendium
Jump to navigation Jump to search
imported>Eric Evers
(New page: =MySQL tutorial= ==Intall== ==Create User== ==Create Database== ==Queries== ===String functions=== ====Pattern Matching==== =====Using Like===== =====Using RegExp=====)
 
imported>Eric Evers
Line 1: Line 1:
=MySQL tutorial=
=MySQL tutorial=


Line 10: Line 9:
=====Using Like=====
=====Using Like=====
=====Using RegExp=====
=====Using RegExp=====
Regular expressions in SQL
--------------------------
Lets create a table.
create table address (name varchar(20));
insert into address values ("people"),("places"),("things"),("ppl");
table address:
+--------+
| name  |
+--------+
| people |
| places |
| things |
| ppl    |
+--------+
select * from address where name RegExp "[p]{2}"
+--------+
| name  |
+--------+
| ppl    |
+--------+
select * from address where name RegExp "p.+p"
+--------+
| name  |
+--------+
| people |
+--------+
======Exercises======
Give a sql regular expression query that will select:
1) only people and places
2) only ppl and places
3) only people and places
4) only things and places

Revision as of 14:34, 5 March 2008

MySQL tutorial

Intall

Create User

Create Database

Queries

String functions

Pattern Matching

Using Like
Using RegExp

Regular expressions in SQL

--------------------------

Lets create a table.

create table address (name varchar(20));
insert into address values ("people"),("places"),("things"),("ppl");
table address:
+--------+
| name   | 
+--------+
| people |
| places |
| things |
| ppl    |
+--------+
select * from address where name RegExp "[p]{2}" 
+--------+
| name   | 
+--------+
| ppl    |
+--------+
select * from address where name RegExp "p.+p" 
+--------+
| name   | 
+--------+
| people |
+--------+
Exercises

Give a sql regular expression query that will select:

1) only people and places 2) only ppl and places 3) only people and places 4) only things and places