Weird results with LEFT JOIN
I have 3 tables:
CREATE TABLE `tbl1` (
`t1c1` char(4)
);
INSERT INTO `tbl1` VALUES ('t1v1');
INSERT INTO `tbl1` VALUES ('t1v2');
CREATE TABLE `tbl2` (
`t2c1` char(4)
);
INSERT INTO `tbl2` VALUES ('t2v1');
INSERT INTO `tbl2` VALUES ('t2v2');
CREATE TABLE `tbl3` (
`t3c1` char(4),
`id` tinyint(3) unsigned NOT NULL auto_increment,
PRIMARY KEY (`id`)
);
INSERT INTO `tbl3` VALUES ('t3v1', 1);
INSERT INTO `tbl3` VALUES ('t3v2', 2);
Issuing query:
SELECT t1c1, t2c1, t3c1
FROM tbl1, tbl2
LEFT JOIN tbl3
ON tbl3.id = 1 + ROUND(RAND())
I expect total 4 rows (tbl1 x tbl2) and random values from third table in third column. But every time I get different number of rows and some values in third column are NULL. Please, can anyone explain, why is it so and how can I get expected behaviour?
Subject
Written By
Posted
Weird results with LEFT JOIN
November 29, 2004 02:11PM
November 29, 2004 02:34PM
November 29, 2004 02:59PM
Sorry, you can't reply to this topic. It has been closed.
Content reproduced on this site is the property of the respective copyright holders.
It is not reviewed in advance by Oracle and does not necessarily represent the opinion
of Oracle or any other party.