What is wrong with this sql query:
select a.*
from samples_order a
inner join
(
select distinct customeremail, min(id) as id
from samples_order group by customeremail
) as b
on a.customeremail = b.customeremail
and a.id = b.id where order_site="blindsuk"
and order_status = "logged" limit 50, 0
order by id desc
Error returned:
You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ‘order by id desc’ at line 8
select a.*
from samples_order a
inner join (
select distinct customeremail, min(id) as id
from samples_order
group by customeremail
) as b on a.customeremail = b.customeremail and a.id = b.id
where order_site="blindsuk"
and order_status = "logged"
limit 50, 0
order by id desc
The
ORDER BYclause should come first beforeLIMITso,