mirror of
https://github.com/MariaDB/server.git
synced 2025-01-16 12:02:42 +01:00
fb006367e5
sql/mysql_priv.h: Auto merged sql/sql_class.cc: Auto merged sql/sql_help.cc: Auto merged sql/sql_select.cc: Auto merged
98 lines
3.9 KiB
Text
98 lines
3.9 KiB
Text
drop table if exists t1,t2,t3;
|
|
CREATE TABLE t1
|
|
(
|
|
FOLDERID VARCHAR(32)BINARY NOT NULL
|
|
, FOLDERNAME VARCHAR(255)BINARY NOT NULL
|
|
, CREATOR VARCHAR(255)BINARY
|
|
, CREATED TIMESTAMP NOT NULL
|
|
, DESCRIPTION VARCHAR(255)BINARY
|
|
, FOLDERTYPE INTEGER NOT NULL
|
|
, MODIFIED TIMESTAMP
|
|
, MODIFIER VARCHAR(255)BINARY
|
|
, FOLDERSIZE INTEGER NOT NULL
|
|
, PARENTID VARCHAR(32)BINARY
|
|
, REPID VARCHAR(32)BINARY
|
|
, ORIGINATOR INTEGER
|
|
, PRIMARY KEY ( FOLDERID )
|
|
) ENGINE=InnoDB;
|
|
CREATE INDEX FFOLDERID_IDX ON t1 (FOLDERID);
|
|
CREATE INDEX CMFLDRPARNT_IDX ON t1 (PARENTID);
|
|
INSERT INTO t1 VALUES("0c9aab05b15048c59bc35c8461507deb", "System", "System", "2003-06-05 16:30:00", "The system content repository folder.", "3", "2003-06-05 16:30:00", "System", "0", NULL, "9c9aab05b15048c59bc35c8461507deb", "1");
|
|
INSERT INTO t1 VALUES("2f6161e879db43c1a5b82c21ddc49089", "Default", "System", "2003-06-09 10:52:02", "The default content repository folder.", "3", "2003-06-05 16:30:00", "System", "0", NULL, "03eea05112b845949f3fd03278b5fe43", "1");
|
|
INSERT INTO t1 VALUES("c373e9f5ad0791724315444553544200", "AddDocumentTest", "admin", "2003-06-09 10:51:25", "Movie Reviews", "0", "2003-06-09 10:51:25", "admin", "0", "2f6161e879db43c1a5b82c21ddc49089", "03eea05112b845949f3fd03278b5fe43", NULL);
|
|
SELECT 'c373e9f5ad0791a0dab5444553544200' IN(SELECT t1.FOLDERID FROM t1 WHERE t1.PARENTID='2f6161e879db43c1a5b82c21ddc49089' AND t1.FOLDERNAME = 'Level1');
|
|
'c373e9f5ad0791a0dab5444553544200' IN(SELECT t1.FOLDERID FROM t1 WHERE t1.PARENTID='2f6161e879db43c1a5b82c21ddc49089' AND t1.FOLDERNAME = 'Level1')
|
|
0
|
|
drop table t1;
|
|
create table t1 (a int) engine=innodb;
|
|
create table t2 (a int) engine=innodb;
|
|
create table t3 (a int) engine=innodb;
|
|
insert into t1 values (1),(2),(3),(4);
|
|
insert into t2 values (10),(20),(30),(40);
|
|
insert into t3 values (1),(2),(10),(50);
|
|
select a from t3 where t3.a in (select a from t1 where a <= 3 union select * from t2 where a <= 30);
|
|
a
|
|
1
|
|
2
|
|
10
|
|
drop table t1,t2,t3;
|
|
CREATE TABLE t1 (
|
|
processor_id INTEGER NOT NULL,
|
|
PRIMARY KEY (processor_id)
|
|
) ENGINE=InnoDB;
|
|
CREATE TABLE t3 (
|
|
yod_id BIGINT UNSIGNED AUTO_INCREMENT NOT NULL,
|
|
login_processor INTEGER UNSIGNED ,
|
|
PRIMARY KEY (yod_id)
|
|
) ENGINE=InnoDB;
|
|
CREATE TABLE t2 (
|
|
processor_id INTEGER NOT NULL,
|
|
yod_id BIGINT UNSIGNED NOT NULL,
|
|
PRIMARY KEY (processor_id, yod_id),
|
|
INDEX (processor_id),
|
|
INDEX (yod_id),
|
|
FOREIGN KEY (processor_id) REFERENCES t1(processor_id),
|
|
FOREIGN KEY (yod_id) REFERENCES t3(yod_id)
|
|
) ENGINE=InnoDB;
|
|
INSERT INTO t1 VALUES (1),(2),(3);
|
|
INSERT INTO t3 VALUES (1,1),(2,2),(3,3);
|
|
INSERT INTO t2 VALUES (1,1),(2,2),(3,3);
|
|
SELECT distinct p1.processor_id, (SELECT y.yod_id FROM t1 p2, t2 y WHERE p2.processor_id = p1.processor_id and p2.processor_id = y.processor_id) FROM t1 p1;
|
|
processor_id (SELECT y.yod_id FROM t1 p2, t2 y WHERE p2.processor_id = p1.processor_id and p2.processor_id = y.processor_id)
|
|
1 1
|
|
2 2
|
|
3 3
|
|
drop table t1,t2,t3;
|
|
CREATE TABLE t1 (
|
|
id int(11) NOT NULL default '0',
|
|
b int(11) default NULL,
|
|
c char(3) default NULL,
|
|
PRIMARY KEY (id),
|
|
KEY t2i1 (b)
|
|
) ENGINE=innodb DEFAULT CHARSET=latin1;
|
|
INSERT INTO t1 VALUES (0,0,'GPL'),(1,0,'GPL'),(2,1,'GPL'),(3,2,'GPL');
|
|
CREATE TABLE t2 (
|
|
id int(11) NOT NULL default '0',
|
|
b int(11) default NULL,
|
|
c char(3) default NULL,
|
|
PRIMARY KEY (id),
|
|
KEY t2i (b)
|
|
) ENGINE=innodb DEFAULT CHARSET=latin1;
|
|
INSERT INTO t2 VALUES (0,0,'GPL'),(1,0,'GPL'),(2,1,'GPL'),(3,2,'GPL');
|
|
select (select max(id) from t2 where b=1 group by b) as x,b from t1 where b=1;
|
|
x b
|
|
2 1
|
|
drop table t1,t2;
|
|
create table t1 (id int not null, value char(255), primary key(id)) engine=innodb;
|
|
create table t2 (id int not null, value char(255)) engine=innodb;
|
|
insert into t1 values (1,'a'),(2,'b');
|
|
insert into t2 values (1,'z'),(2,'x');
|
|
select t2.id,t2.value,(select t1.value from t1 where t1.id=t2.id) from t2;
|
|
id value (select t1.value from t1 where t1.id=t2.id)
|
|
1 z a
|
|
2 x b
|
|
select t2.id,t2.value,(select t1.value from t1 where t1.id=t2.id) from t2;
|
|
id value (select t1.value from t1 where t1.id=t2.id)
|
|
1 z a
|
|
2 x b
|
|
drop table t1,t2;
|