Could you please help me with this subject. We are using date filter since many time now and discovering a behaviour.
I made an exemple here : http://sqlfiddle.com/#!9/8f01f4/3
As you can see the join query returns 'a' and 'b' data. When just adding a left join I loose 'b' data.
Could you please explain why this behaviour ?
If I change the where like that : a.jma = '2020-05-18' OR a.jma = 20200518 it works. But I would like to understand to not reproduce this "bug".
Thanks
The codes copied from the fiddle:
CREATE TABLE `a` (
`clef` INT(11) NOT NULL AUTO_INCREMENT,
`jma` DATE NOT NULL DEFAULT '0000-00-00',
PRIMARY KEY (`clef`),
UNIQUE KEY `jma` (`jma`)
) ENGINE=MYISAM DEFAULT CHARSET=latin1
;
INSERT INTO a VALUES (1,20200518);
CREATE TABLE `b` (
`clef` INT(11) NOT NULL AUTO_INCREMENT,
`jma` DATE NOT NULL DEFAULT '0000-00-00',
PRIMARY KEY (`clef`),
UNIQUE KEY `jma` (`jma`)
) ENGINE=MYISAM DEFAULT CHARSET=latin1 ;
INSERT INTO b VALUES (1,20200518);
SELECT a.clef , b.clef
FROM a AS a
JOIN b AS b ON a.jma = b.jma
WHERE a.jma = '20200518';
SELECT a.clef , b.clef
FROM a AS a
LEFT JOIN b AS b ON a.jma = b.jma
WHERE a.jma = '20200518' ;
WHERE a.jma = '2020-05-18'
simply.