SELECT sortsnum FROM products P left join products_categorys_links L on L.product_id=P.id left join categorys C on C.id=L.category_id WHERE P.sortsnum<>'' and P.producttype='QA' and C.factory_id= ORDER BY rand() LIMIT 8You 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 rand() LIMIT 8' at line 1