我有 4 张桌子
- 产品
- 地位
- 订单
- 订单_产品。
使用以下查询我得到了正确的结果,但它的顺序不正确,即结果是通过子查询获得的。我希望结果顺序作为子查询结果。
SELECT
p.products_id, p.products_image, p.products_tax_class_id,
pd.products_name, if(s.status, s.specials_new_products_price,
p.products_price) as products_price
FROM
products p LEFT JOIN specials s
ON p.products_id = s.products_id, products_description pd
WHERE
p.products_status = '1'
AND p.products_id = pd.products_id
AND pd.language_id = '2'
AND p.products_id in (
SELECT * from (
SELECT
distinct(op.products_id)
FROM
orders_products op,orders o
WHERE
op.orders_id=o.orders_id
AND o.customers_id='27'
ORDER BY
o.date_purchased
DESC LIMIT 0,10
) AS temptable
)