I have a query:
select
distinct orders.id,
orders.amount,
CONCAT(users.firstName, ' ', users.lastName) as username,
users.email,
users.id as userId,
users.country,
users.phoneNumber,
GROUP_CONCAT(DISTINCT products.name SEPARATOR ' ') as productsList,
orders.invoiceUrl,
coupons.name as couponName,
users.firstName,
users.lastName
from orders
inner join users
on orders.userId=users.id
left join orderItems
on orderItems.orderId=orders.id
left join products
on orderItems.productId=products.id
left join coupons
on orders.coupon=coupons.id
where
orders.id = 'mike'
OR CONCAT(users.firstName, ' ', users.lastName) like '%mike%'
OR users.email like '%mike%'
group by orders.id
order by orders.created desc
limit 0,25;
It works in shell:
But, it doesn't work with mysql2. It throws an error:
Unknown column 'users.firstName' in 'where clause'
What is causing this error with node-mysql2?