我遇到了一个非常奇怪的问题。
此查询无效:
/*application/config/hooks.php*/
$hook['pre_controller'][] =
array(
'class' => 'MyClass',
'function' => 'Myfunction',
'filename' => 'Myclass.php',
'filepath' => 'hooks',
'params' => array('beer', 'wine', 'snacks')
);
/*application/config/config.php*/
$config['enable_hooks'] = TRUE;
错误:
SELECT
t1.status :: TEXT,
t1.total_amount :: float AS amount
FROM accounting.payment_in_records AS t1
UNION ALL
SELECT
t1.fees :: float AS amount,
'Processed' :: TEXT AS status
FROM accounting.payment_out_record_detail_groups AS t1
WHERE t1.fees > 0;
但是此查询有效:
[42804] ERROR: UNION types text and double precision cannot be matched Position: 147
所以列顺序必须相同?
答案 0 :(得分:2)
是的,顺序必须相同。决定因素不是别名列,而是 position 列。
有关“ UNION
兼容数据类型”的详细信息,请参见the documentation。
文档具有
解析算法分别应用于联合查询的每个输出列。
它无法清楚地表明一列是通过其位置标识的。