I use as RDBMS the version 5.5.24-log of MySql.
With this sql query in output I have all records presents on the two tables tbl_1
and tbl_2
:
SELECT * FROM `tbl_1` CB
JOIN `tbl_2` A ON A.xCode = CB.xCode
AND RIGHT (A.xElement, 1) = CB.xElement
WHERE
CB.xType IN ('A')
AND MONTH(xDate) BETWEEN 1 AND 4
ORDER BY xDate DESC;
Now I need extract from tbl_1
all records not presents in tbl_2
and I have tried this sql query but I have error
Lost connection to MySQL server during query
SELECT i.* FROM
`tbl_1` i
LEFT JOIN `tbl_2` o ON o.xCode = i.xCode_cabina
AND RIGHT (o.xElement, 1) = i.xElement
WHERE
i.xType IN ('A')
AND MONTH(xDate) BETWEEN 1 AND 4
AND o.xElement IS NULL ;
Can you please help me figure out the problem?
Thanks in advance.