Welcome to MySQL Workbench:MySQL正規表示式
正規表示式:
MySQL 同樣也支援其他正規表示式的匹配, MySQL中使用 REGEXP 操作符來進行正規表示式匹配。
如果您瞭解PHP或Perl,那麼操作起來就非常簡單,因為MySQL的正規表示式匹配與這些指令碼的類似。
CREATE TABLE test_NO1(
test_NO1_id INT NOT NULL AUTO_INCREMENT,
test_NO1_title VARCHAR(100) NOT NULL,
test_NO1_author VARCHAR(40) NOT NULL,
test_NO1_date DATE,
PRIMARY KEY ( test_NO1_id )
)ENGINE=InnoDB;
drop table test_no1;
INSERT INTO test_NO1
(test_NO1_title, test_NO1_author, test_NO1_date )
VALUES
("programb", "welcome to programb", NOW());
select * from test_NO1;
INSERT INTO test_NO1
(test_NO1_title, test_NO1_author, test_NO1_date )
VALUES
("programb2", "welcome to programb2", NOW());
INSERT INTO test_NO1
(test_NO1_title, test_NO1_author, test_NO1_date )
VALUES
("programb3", "welcome to programb3", NOW());
SELECT * from test_NO1 WHERE test_NO1_title='programb2';
SELECT * from test_NO1;
update test_NO1 SET test_NO1_title='programb100' WHERE test_NO1_id=1;
SELECT * from test_NO1 where test_NO1_id=1;
SELECT * from test_NO1;
DELETE FROM test_NO1 WHERE test_NO1_id=1;
SELECT * from test_NO1;
SELECT * from test_NO1 WHERE test_NO1_title LIKE '%programb2';
INSERT INTO test_NO1
(test_NO1_title, test_NO1_author, test_NO1_date )
VALUES
("programb2", "welcome.to.programb2", NOW());
SELECT * from test_NO1 WHERE test_NO1_author LIKE '%programb2';
SELECT * from test_NO1 WHERE test_NO1_author LIKE '%to%';
SELECT * from test_NO1 WHERE test_NO1_author LIKE 'welcome%';
SELECT * from test_NO1;
CREATE TABLE test_NO2(
test_NO1_id INT NOT NULL AUTO_INCREMENT,
test_NO1_title VARCHAR(100) NOT NULL,
test_NO1_author VARCHAR(40) NOT NULL,
test_NO1_date DATE,
PRIMARY KEY ( test_NO1_id )
)ENGINE=InnoDB;
INSERT INTO test_NO2
(test_NO1_title, test_NO1_author, test_NO1_date )
VALUES
("programb2", "welcome.to.programb2", NOW());
SELECT * from test_NO2;
SELECT test_NO1_author FROM test_no1
UNION
SELECT test_NO1_author FROM test_no2
ORDER BY test_NO1_author;
SELECT test_NO1_author FROM test_no1
UNION all
SELECT test_NO1_author FROM test_no2
ORDER BY test_NO1_author;
select * from test_no1 order by test_NO1_date asc;
INSERT INTO test_NO1
(test_NO1_title, test_NO1_author, test_NO1_date )
VALUES
("programb4", "welcome to programb4", NOW());
INSERT INTO test_NO1
(test_NO1_title, test_NO1_author, test_NO1_date )
VALUES
("programb5", "welcome to programb5", NOW());
select * from test_no1 order by test_NO1_date asc;
select * from test_no1 order by test_NO1_date desc;
select test_NO1_title, count(*) from test_no1 group by test_NO1_title;
select test_NO1_title, sum(test_NO1_id) from test_no1 group by test_NO1_title;
select test_NO1_title, avg(test_NO1_id) from test_no1 group by test_NO1_title;
SELECT * from test_NO1;
SELECT * from test_no2;
INSERT INTO test_NO2
(test_NO1_title, test_NO1_author, test_NO1_date )
VALUES
("programb4", "welcome to programb4", NOW());
INSERT INTO test_NO2
(test_NO1_title, test_NO1_author, test_NO1_date )
VALUES
("programb2", "welcome to programb2", NOW());
SELECT * from test_no2;
select t1.test_NO1_title, t2.test_NO1_date from test_no1 t1, test_no2 t2 where t1.test_NO1_date=t2.test_NO1_date;
select t1.test_NO1_title, t2.test_NO1_date from test_no1 t1 left join test_no2 t2 on t1.test_NO1_date=t2.test_NO1_date;
select t1.test_NO1_title, t2.test_NO1_date from test_no1 t1 right join test_no2 t2 on t1.test_NO1_date=t2.test_NO1_date;
SELECT * from test_no2;
INSERT INTO test_NO2
(test_NO1_title, test_NO1_author, test_NO1_date )
VALUES
("programb2", "welcome", NOW());
SELECT * from test_no2;
select * from test_no2 where test_NO1_author is null;
INSERT INTO test_NO2
(test_NO1_title, test_NO1_author )
VALUES
("programb2", "welcome");
INSERT INTO test_NO2
(test_NO1_title, test_NO1_author )
VALUES
("programb2", "welcome");
INSERT INTO test_NO2
(test_NO1_title, test_NO1_author )
VALUES
("programb2", "welcome");
SELECT * from test_no2;
select * from test_no2 where test_NO1_date is null;
select * from test_no2 where test_NO1_date is not null;
select * from test_no1 where test_NO1_title regexp '^pro';
select * from test_no1 where test_NO1_title regexp '2$';
select * from test_no1 where test_NO1_title regexp 'gra';
select * from test_no1 where test_NO1_title regexp '^[pro]|5$';
select * from test_no1 where test_NO1_title regexp '^pro';
select * from test_no1 where test_NO1_title regexp '2$';
select * from test_no1 where test_NO1_title regexp 'gra';
select * from test_no1 where test_NO1_title regexp '^[pro]|5$';
相關文章
- MySQL 正規表示式MySql
- MySQL正規表示式MySql
- Welcome to MySQL Workbench:MySQL 複製表MySql
- MySQL-正規表示式詳解MySql
- MySQL必知必會》正規表示式MySql
- 開心檔之MySQL 正規表示式MySql
- 使用MySQL之用正規表示式進行搜尋MySql
- [MYSQL-9]用正規表示式進行搜尋MySql
- 正規表示式
- 【正規表示式】常用的正規表示式(數字,漢字,字串,金額等的正規表示式)字串
- 【JavaScript】正規表示式JavaScript
- php –正規表示式PHP
- 正規表示式 教程
- 正規表示式 split()
- java正規表示式Java
- PHP正規表示式PHP
- javascript正規表示式JavaScript
- 【java】正規表示式Java
- 初探正規表示式
- [js]正規表示式JS
- js正規表示式JS
- javascript–正規表示式JavaScript
- ORACLE 正規表示式Oracle
- oracle正規表示式Oracle
- js 正規表示式JS
- ultraedit正規表示式
- 正規表示式合集
- SQL正規表示式SQL
- 正規表示式(java)Java
- JavaScript 正規表示式JavaScript
- 常用正規表示式
- JAVA+MYSQL+CSV用正規表示式獲取CPU天梯分數JavaMySql
- Oracle正規表示式函式Oracle函式
- JS常用正規表示式及驗證時間的正規表示式JS
- 詳解正規表示式
- 正規表示式基礎
- Python——正規表示式Python
- js正規表示式速查JS