我想过滤一个表格,但是在表格中有一个user_id
列,我想过滤它的真实表格(我的意思是users.username
)。
我的代码:
SELECT SQL_CALC_FOUND_ROWS `id`, `user_id`, `payment_type`,
`is_paid`, `is_invoiced`, `invoice_number`, `created_at`, `ip`,
`data`, `coupon_code`, `payment_total`,
(select CONCAT(users.name,' ',users.surname) from users where users.id = orders.user_id) as fullname
FROM orders
WHERE (`fullname` LIKE '%M%' OR `payment_type` LIKE '%M%') ORDER BY `is_invoiced` asc
当我执行它时,会出现这样的错误:Unknown column 'fullname' in 'where clause'
.
我该如何解决?