我真的不明白为什么3个select查询有不同的行为,尽管第2个和第3个在意义上是相似的。有错误的第二个查询和无错误的第三个查询
第一个查询-1使用别名属性连接-ok
SELECT
id as bet_slip_id,
placed,
settled,
status,
fk_user as user_id,
tax_system_id,
tax_system_name,
fk_agent as agent_id
FROM
stage.bet_slip
ANY LEFT JOIN (
SELECT
id as tax_system_id,
name as tax_system_name
FROM stage.tax_system
) ts
ON fk_tax_system = ts.tax_system_id
WHERE
settled < '2019-05-01 00:00:00'
AND settled >= '2019-04-16 00:00:00'
limit $limit
第二个查询-具有别名属性的2个联接-错误
SELECT
id as bet_slip_id,
placed,
settled,
status,
fk_user as user_id,
tax_system_id,
tax_system_name,
leg_bonus_scheme_id,
leg_bonus_scheme_name,
fk_agent as agent_id
FROM
stage.bet_slip
ANY LEFT JOIN (
SELECT
id as tax_system_id,
name as tax_system_name
FROM stage.tax_system
) ts
ON fk_tax_system = ts.tax_system_id
ANY LEFT JOIN (
SELECT
id as leg_bonus_scheme_id,
name as leg_bonus_scheme_name
FROM stage.leg_bonus_scheme
) ls
ON fk_leg_bonus_scheme = ls.leg_bonus_scheme_id
WHERE
settled < '2019-05-01 00:00:00'
AND settled >= '2019-04-16 00:00:00'
limit $limit
第三个查询-2与另一个别名属性连接-ok
SELECT
id as bet_slip_id,
placed,
settled,
status,
fk_user as user_id,
fk_tax_system as tax_system_id,
tax_system_name,
leg_bonus_scheme_id,
leg_bonus_scheme_name,
fk_agent as agent_id
FROM
stage.bet_slip
ANY LEFT JOIN (
SELECT
id as fk_tax_system,
name as tax_system_name
FROM stage.tax_system
) ts
ON fk_tax_system = ts.fk_tax_system
ANY LEFT JOIN (
SELECT
id as leg_bonus_scheme_id,
name as leg_bonus_scheme_name
FROM stage.leg_bonus_scheme
) ls
ON fk_leg_bonus_scheme = ls.leg_bonus_scheme_id
WHERE
settled < '2019-05-01 00:00:00'
AND settled >= '2019-04-16 00:00:00'
limit $limit
第二次查询结果出错:
code:47,e.displaytext()=db::exception:未知标识符:tax\u system\u id,context:query:'select id as bet\u slip\u id,placed,settled,status,fk\u user as user\u id,tax\u system\u id,tax\u system\u name,leg\u bonus\u scheme\u id,leg\u bonus\u scheme\u name,fk\u agent as agent\u id from(select*from stage.bet\u slip any left join)(select id as tax\u system\u id,名称作为tax\u system\u stage.tax\u system中的名称)作为fk\u tax\u system上的ts= --ts.tax_system_id
)任何左连接(选择id作为leg\u bonus\u scheme\u id,name as leg\u bonus\u scheme\u name from stage.leg\u bonus\u scheme)as ls on fk\u leg\u bonus\u scheme=leg\u bonus\u scheme\u id其中(已结算<'2019-05-01 00:00:00')和(已结算>='2019-04-16 00:00:00')限制100000'必需的\u名称:'fk\U leg\U bonus\U scheme''fk\U agent'/'agent\U id''leg\U bonus\U scheme\U id''placed'/'bet\U slip\U id''settled''leg\U bonus\U scheme\U name''status''tax\U system\U name''fk\U user'/'user\U id''tax\U system\U id'source\U tables:'ls'table\U Alias:'ls'complex\U Alias:masked\U columns:array\U join\U columns:source\U columns:'id''fk\U user''placed''status''settled''fk\U agent'“fk\腿\奖金\方案”“税务\系统\名称”(版本19.5.3.8(官方版本))
暂无答案!
目前还没有任何答案,快来回答吧!