mirror of
https://github.com/MariaDB/server.git
synced 2025-07-30 16:24:05 +03:00
Merge sanja.is.com.ua:/home/bell/mysql/bk/mysql-4.1
into sanja.is.com.ua:/home/bell/mysql/bk/work-delete-4.1
This commit is contained in:
@ -1,4 +1,4 @@
|
||||
drop table if exists t1;
|
||||
drop table if exists t1,t11,t12,t2;
|
||||
CREATE TABLE t1 (a tinyint(3), b tinyint(5));
|
||||
INSERT INTO t1 VALUES (1,1);
|
||||
INSERT LOW_PRIORITY INTO t1 VALUES (1,2);
|
||||
@ -58,3 +58,65 @@ select count(*) from t1;
|
||||
count(*)
|
||||
0
|
||||
drop table t1;
|
||||
create table t11 (a int NOT NULL, b int, primary key (a));
|
||||
create table t12 (a int NOT NULL, b int, primary key (a));
|
||||
create table t2 (a int NOT NULL, b int, primary key (a));
|
||||
insert into t11 values (0, 10),(1, 11),(2, 12);
|
||||
insert into t12 values (33, 10),(0, 11),(2, 12);
|
||||
insert into t2 values (1, 21),(2, 12),(3, 23);
|
||||
select * from t11;
|
||||
a b
|
||||
0 10
|
||||
1 11
|
||||
2 12
|
||||
select * from t12;
|
||||
a b
|
||||
33 10
|
||||
0 11
|
||||
2 12
|
||||
select * from t2;
|
||||
a b
|
||||
1 21
|
||||
2 12
|
||||
3 23
|
||||
delete t11.*, t12.* from t11,t12 where t11.a = t12.a and t11.b <> (select b from t2 where t11.a < t2.a);
|
||||
ERROR 21000: Subquery returns more than 1 row
|
||||
select * from t11;
|
||||
a b
|
||||
0 10
|
||||
1 11
|
||||
2 12
|
||||
select * from t12;
|
||||
a b
|
||||
33 10
|
||||
0 11
|
||||
2 12
|
||||
delete ignore t11.*, t12.* from t11,t12 where t11.a = t12.a and t11.b <> (select b from t2 where t11.a < t2.a);
|
||||
Warnings:
|
||||
Error 1241 Subquery returns more than 1 row
|
||||
Error 1241 Subquery returns more than 1 row
|
||||
select * from t11;
|
||||
a b
|
||||
0 10
|
||||
1 11
|
||||
select * from t12;
|
||||
a b
|
||||
33 10
|
||||
0 11
|
||||
insert into t11 values (2, 12);
|
||||
delete from t11 where t11.b <> (select b from t2 where t11.a < t2.a);
|
||||
ERROR 21000: Subquery returns more than 1 row
|
||||
select * from t11;
|
||||
a b
|
||||
0 10
|
||||
1 11
|
||||
2 12
|
||||
delete ignore from t11 where t11.b <> (select b from t2 where t11.a < t2.a);
|
||||
Warnings:
|
||||
Error 1241 Subquery returns more than 1 row
|
||||
Error 1241 Subquery returns more than 1 row
|
||||
select * from t11;
|
||||
a b
|
||||
0 10
|
||||
1 11
|
||||
drop table t11, t12, t2;
|
||||
|
@ -1569,32 +1569,3 @@ INSERT INTO t2 VALUES (100, 200, 'C');
|
||||
SELECT DISTINCT COLC FROM t1 WHERE COLA = (SELECT COLA FROM t2 WHERE COLB = 200 AND COLC ='C' LIMIT 1);
|
||||
COLC
|
||||
DROP TABLE t1, t2;
|
||||
create table t11 (a int NOT NULL, b int, primary key (a));
|
||||
create table t12 (a int NOT NULL, b int, primary key (a));
|
||||
create table t2 (a int NOT NULL, b int, primary key (a));
|
||||
insert into t11 values (0, 10),(1, 11),(2, 12);
|
||||
insert into t12 values (33, 10),(22, 11),(2, 12);
|
||||
insert into t2 values (1, 21),(2, 12),(3, 23);
|
||||
select * from t11;
|
||||
a b
|
||||
0 10
|
||||
1 11
|
||||
2 12
|
||||
select * from t12;
|
||||
a b
|
||||
33 10
|
||||
22 11
|
||||
2 12
|
||||
select * from t2;
|
||||
a b
|
||||
1 21
|
||||
2 12
|
||||
3 23
|
||||
delete t11.*, t12.* from t11,t12 where t11.a = t12.a and t11.b > (select b from t2);
|
||||
ERROR 21000: Subquery returns more than 1 row
|
||||
select * from t2;
|
||||
a b
|
||||
1 21
|
||||
2 12
|
||||
3 23
|
||||
drop table t11, t12, t2;
|
||||
|
@ -3,7 +3,7 @@
|
||||
#
|
||||
|
||||
--disable_warnings
|
||||
drop table if exists t1;
|
||||
drop table if exists t1,t11,t12,t2;
|
||||
--enable_warnings
|
||||
CREATE TABLE t1 (a tinyint(3), b tinyint(5));
|
||||
INSERT INTO t1 VALUES (1,1);
|
||||
@ -71,3 +71,30 @@ delete from t1 where 3 > 2;
|
||||
select count(*) from t1;
|
||||
|
||||
drop table t1;
|
||||
|
||||
#
|
||||
# IGNORE option
|
||||
#
|
||||
create table t11 (a int NOT NULL, b int, primary key (a));
|
||||
create table t12 (a int NOT NULL, b int, primary key (a));
|
||||
create table t2 (a int NOT NULL, b int, primary key (a));
|
||||
insert into t11 values (0, 10),(1, 11),(2, 12);
|
||||
insert into t12 values (33, 10),(0, 11),(2, 12);
|
||||
insert into t2 values (1, 21),(2, 12),(3, 23);
|
||||
select * from t11;
|
||||
select * from t12;
|
||||
select * from t2;
|
||||
-- error 1241
|
||||
delete t11.*, t12.* from t11,t12 where t11.a = t12.a and t11.b <> (select b from t2 where t11.a < t2.a);
|
||||
select * from t11;
|
||||
select * from t12;
|
||||
delete ignore t11.*, t12.* from t11,t12 where t11.a = t12.a and t11.b <> (select b from t2 where t11.a < t2.a);
|
||||
select * from t11;
|
||||
select * from t12;
|
||||
insert into t11 values (2, 12);
|
||||
-- error 1241
|
||||
delete from t11 where t11.b <> (select b from t2 where t11.a < t2.a);
|
||||
select * from t11;
|
||||
delete ignore from t11 where t11.b <> (select b from t2 where t11.a < t2.a);
|
||||
select * from t11;
|
||||
drop table t11, t12, t2;
|
||||
|
@ -1009,21 +1009,3 @@ INSERT INTO t1 VALUES (1,1,'1A3240'), (1,2,'4W2365');
|
||||
INSERT INTO t2 VALUES (100, 200, 'C');
|
||||
SELECT DISTINCT COLC FROM t1 WHERE COLA = (SELECT COLA FROM t2 WHERE COLB = 200 AND COLC ='C' LIMIT 1);
|
||||
DROP TABLE t1, t2;
|
||||
|
||||
#
|
||||
# errors handling
|
||||
#
|
||||
|
||||
create table t11 (a int NOT NULL, b int, primary key (a));
|
||||
create table t12 (a int NOT NULL, b int, primary key (a));
|
||||
create table t2 (a int NOT NULL, b int, primary key (a));
|
||||
insert into t11 values (0, 10),(1, 11),(2, 12);
|
||||
insert into t12 values (33, 10),(22, 11),(2, 12);
|
||||
insert into t2 values (1, 21),(2, 12),(3, 23);
|
||||
select * from t11;
|
||||
select * from t12;
|
||||
select * from t2;
|
||||
-- error 1241
|
||||
delete t11.*, t12.* from t11,t12 where t11.a = t12.a and t11.b > (select b from t2);
|
||||
select * from t2;
|
||||
drop table t11, t12, t2;
|
||||
|
Reference in New Issue
Block a user