使用where-in和一个临时表feed作为参数,mysql查询引擎返回一个完全出乎意料的结果。
CREATE TABLE MDC_Customer (StoreId char(20), Name nvarchar(100));
CREATE TABLE MDC_Caixa (Data datetime, CaixaId int, StoreId char(20), Revenue DECIMAL(15,2));
CREATE TEMPORARY TABLE IF NOT EXISTS StoreRev (Stores nvarchar(44));
TRUNCATE TABLE StoreRev;
INSERT INTO StoreRev SELECT StoreId FROM MDC_Customer WHERE StoreId IN ('00013');
CREATE TEMPORARY TABLE IF NOT EXISTS CaixaRev (CaixaID int, StoreID char(20));
TRUNCATE TABLE CaixaRev;
INSERT INTO CaixaRev
SELECT CaixaId, StoreId
FROM MDC_Caixa CX
WHERE CAST(CX.Data AS date) BETWEEN '2018-05-01' AND '2018-05-01'
AND CX.StoreID IN (SELECT StoreID FROM StoreRev);
SELECT * FROM StoreRev;
SELECT * FROM CaixaRev;
DROP TEMPORARY TABLE StoreRev;
DROP TEMPORARY TABLE CaixaRev;
实际结果:mysql将(select storeid from storerev)中的cx.storeid计算为true,而不是抛出“无效语法错误”;
预期结果:mysql应该抛出一个“invalid syntax error”,报告storerev临时表中没有“storeid”字段;
暂无答案!
目前还没有任何答案,快来回答吧!