Hello,
I have limited access and control of the data I am working with. The data comes from a data warehouse. relevant queries results are stored in temp tables. The number of records stored in each table is the same. A simplified example would be;
CREATE TABLE IF NOT EXISTS `t1` (
`index` int(5) DEFAULT NULL,
`data` varchar(10) DEFAULT NULL,
`t1_codex` int(6) DEFAULT NULL,
`other` int(5) DEFAULT NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1;
simplifed data;
INSERT INTO `t1` (`index`, `build`, `t1_codex`, `other`) VALUES
(1, 'xe4510554xx39001', 12, 0),
(2, 'xf4510554xx40002', 45, 3),
(3, 'xf4510554xx41055', 14, 4),
(4, 'xf4510554xx42005', 335, 3);
There can be many of these temp tables created. More than 20 in some instances.
I need to select all the data in a single column from each of these tables. Using the above example
t1.t1_codex
t2.t2_codex
t3.t3_codex
etc...
and produce a result set such as;
t1_codex t2_codex t3_codex
12 77 04
45 96 89
14 05 66
435 44 01
etc...
BUT, problems.
any select I do produces a Cartesian product...
SELECT `t1`.`t1_codex` , `t2`.`t2_codex` , `t3`.`t3_codex`
FROM `t3` , `t2` , `t1`
ORDER BY `t1`.`t1_codex` ASC , `t2`.`t2_codex` ASC , `t3`.`t3_codex` ASC
LIMIT 0 , 30
I tried selecting the relevant data into a new table, no joy... I have been looking a this too long, I am sure there is a simple solution to this but i can't see it at the moment and need someone elses input. thanks in advance.
I have limited access and control of the data I am working with. The data comes from a data warehouse. relevant queries results are stored in temp tables. The number of records stored in each table is the same. A simplified example would be;
CREATE TABLE IF NOT EXISTS `t1` (
`index` int(5) DEFAULT NULL,
`data` varchar(10) DEFAULT NULL,
`t1_codex` int(6) DEFAULT NULL,
`other` int(5) DEFAULT NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1;
simplifed data;
INSERT INTO `t1` (`index`, `build`, `t1_codex`, `other`) VALUES
(1, 'xe4510554xx39001', 12, 0),
(2, 'xf4510554xx40002', 45, 3),
(3, 'xf4510554xx41055', 14, 4),
(4, 'xf4510554xx42005', 335, 3);
There can be many of these temp tables created. More than 20 in some instances.
I need to select all the data in a single column from each of these tables. Using the above example
t1.t1_codex
t2.t2_codex
t3.t3_codex
etc...
and produce a result set such as;
t1_codex t2_codex t3_codex
12 77 04
45 96 89
14 05 66
435 44 01
etc...
BUT, problems.
any select I do produces a Cartesian product...
SELECT `t1`.`t1_codex` , `t2`.`t2_codex` , `t3`.`t3_codex`
FROM `t3` , `t2` , `t1`
ORDER BY `t1`.`t1_codex` ASC , `t2`.`t2_codex` ASC , `t3`.`t3_codex` ASC
LIMIT 0 , 30
I tried selecting the relevant data into a new table, no joy... I have been looking a this too long, I am sure there is a simple solution to this but i can't see it at the moment and need someone elses input. thanks in advance.