SELECT itemid, title, itemDescription, standardPrice, "1" as relevance FROM items LEFT JOIN ( SELECT item_id, COUNT(*) AS ordered_cnt FROM ordered_items GROUP BY item_id ) AS ordered ON ordered.item_id = items.itemid WHERE multiplesof = ? AND items.stock = ? GROUP BY itemid ORDER BY relevance DESC, ordered.ordered_cnt DESC LIMIT 0, 24 Sex Toys & Adult Toys, secure discreet shipping, Buy Online!