issue663.result 3.1 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89
create table t11 (a int NOT NULL, b int, primary key (a))ENGINE=TIANMU;
create table t12 (a int NOT NULL, b int, primary key (a))ENGINE=TIANMU;
insert into t11 values (0, 10),(1, 11),(2, 12);
insert into t12 values (33, 10),(0, 11),(2, 12);
explain select t11.*,t12.* from t11,t12 where t11.a = t12.a;
id	select_type	table	partitions	type	possible_keys	key	key_len	ref	rows	filtered	Extra
1	SIMPLE	t11	NULL	ALL	PRIMARY	NULL	NULL	NULL	3	100.00	NULL
1	SIMPLE	t12	NULL	eq_ref	PRIMARY	PRIMARY	4	test.t11.a	1	100.00	NULL
select t11.*,t12.* from t11,t12 where t11.a = t12.a;
a	b	a	b
0	10	0	11
2	12	2	12
explain delete t11.*,t12.* from t11,t12 where t11.a = t12.a;
id	select_type	table	partitions	type	possible_keys	key	key_len	ref	rows	filtered	Extra
1	DELETE	t11	NULL	ALL	NULL	NULL	NULL	NULL	3	100.00	NULL
1	DELETE	t12	NULL	ALL	NULL	NULL	NULL	NULL	3	33.33	Using where
delete t11.*,t12.* from t11,t12 where t11.a = t12.a;
select * from t11;
a	b
1	11
select * from t12;
a	b
33	10
drop table t11,t12;
CREATE TABLE t1 (a int not null,b int not null)ENGINE=TIANMU;
CREATE TABLE t2 (a int not null, b int not null, primary key (a,b))ENGINE=TIANMU;
CREATE TABLE t3 (a int not null, b int not null, primary key (a,b))ENGINE=TIANMU;
insert into t1 values (1,1),(2,1),(1,3);
insert into t2 values (1,1),(2,2),(3,3);
insert into t3 values (1,1),(2,1),(1,3);
delete t2.*,t3.* from t1,t2,t3 where t1.a=t2.a AND t2.b=t3.a and t1.b=t3.b;
select * from t1;
a	b
1	1
2	1
1	3
select * from t2;
a	b
3	3
select * from t3;
a	b
drop table t1,t2,t3;
CREATE TABLE t1 (sku int PRIMARY KEY, pr int)engine=tianmu;
CREATE TABLE t2 (sku int PRIMARY KEY, sppr int, name varchar(255))engine=tianmu;
INSERT INTO t1 VALUES
(10, 10), (20, 10), (30, 20), (40, 30), (50, 10), (60, 10);
INSERT INTO t2 VALUES 
(10, 10, 'aaa'), (20, 10, 'bbb'), (30, 10, 'ccc'), (40, 20, 'ddd'),
(50, 10, 'eee'), (60, 20, 'fff'), (70, 20, 'ggg'), (80, 30, 'hhh');
SELECT t2.sku, t2.sppr, t2.name, t1.sku, t1.pr
FROM t2, t1 WHERE t2.sku=20 AND (t2.sku=t1.sku OR t2.sppr=t1.sku);
sku	sppr	name	sku	pr
20	10	bbb	10	10
20	10	bbb	20	10
delete t2,t1
FROM t2, t1 WHERE t2.sku=20 AND (t2.sku=t1.sku OR t2.sppr=t1.sku);
SELECT t2.sku, t2.sppr, t2.name, t1.sku, t1.pr
FROM t2, t1 WHERE t2.sku=20 AND (t2.sku=t1.sku OR t2.sppr=t1.sku);
sku	sppr	name	sku	pr
drop table t1,t2;
CREATE TABLE t1 (sku int PRIMARY KEY, pr int)engine=tianmu;
CREATE TABLE t2 (sku int PRIMARY KEY, sppr int, name varchar(255))engine=tianmu;
INSERT INTO t1 VALUES
(10, 10), (20, 10), (30, 20), (40, 30), (50, 10), (60, 10);
INSERT INTO t2 VALUES 
(10, 10, 'aaa'), (20, 10, 'bbb'), (30, 10, 'ccc'), (40, 20, 'ddd'),
(50, 10, 'eee'), (60, 20, 'fff'), (70, 20, 'ggg'), (80, 30, 'hhh');
SELECT t2.sku, t2.sppr, t2.name, t1.sku, t1.pr  
FROM t1,t2  WHERE 
t1.sku=10 AND 
(t2.sku=20 AND 
(t2.sku=t1.sku OR 
t2.sppr=t1.sku));
sku	sppr	name	sku	pr
20	10	bbb	10	10
delete t1,t2  
FROM t1,t2  WHERE 
t1.sku=10 AND 
(t2.sku=20 AND 
(t2.sku=t1.sku OR 
t2.sppr=t1.sku));
SELECT t2.sku, t2.sppr, t2.name, t1.sku, t1.pr  
FROM t1,t2  WHERE 
t1.sku=10 AND 
(t2.sku=20 AND 
(t2.sku=t1.sku OR 
t2.sppr=t1.sku));
sku	sppr	name	sku	pr
drop table t1,t2;