You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'AND A.Catelog_ID=B.Catelog_ID AND B.Sort_ID=C.Sort_ID ORDER BY B.Ord,A.Ord LIMIT' at line 1