SELECT
clv.*, cla.customer_id, cla.mobile_no, o.name
FROM
closed_loyalty_voucher clv
JOIN
closed_loyalty_redemption_details clrd ON (clv.issued_to = clrd.customer_id
AND clrd.voucher_number = clv.voucher_number)
JOIN
closed_loyalty_setup_master clsm ON (clsm.id = clrd.setup_id)
JOIN
closed_loyalty_accounts cla ON (cla.program_id = clsm.id
AND cla.created_by = clrd.customer_id)
JOIN
outlets o ON (clrd.outlet = o.id)
WHERE
clv.status = 'Redeemed'
AND (company LIKE '%%' OR mobile_no LIKE '%%'
OR name LIKE '%%'
OR cla.customer_id LIKE '%%')
GROUP BY clv.id
ORDER BY clv.redeemed_date DESC
这是我的查询获取错误消息#1054 - 'where子句'中的未知列'cla.customer_id'请帮忙??
答案 0 :(得分:0)
您在整个表点列名称周围放置了一个反引号(或带引号的标识符)。如果你使用反引号,你将它们放在桌子周围,然后点,然后围绕字段名称。
在这种情况下,不需要反引号,因为您在列名中使用下划线。所以将其更改为<html>
<head>
<!-- all head elements -->
</head>
<body>
<?= $this->fetch('content') ?>
<!-- all js includes -->
</body>
</html>
。
唯一需要引用标识符的时间是列名或表名使用关键字或包含空格的时间。请参阅https://dba.stackexchange.com/questions/23129/benefits-of-using-backtick-in-mysql-queries。