Okay and do you know what those product ids are? how do you determine which those rows are?
The good news is once you can explain that it is pretty easy to do.
Lets say it is by productid and you want these rows listed first and in exactly this order:
45
37
18
101
and then the rest of the products below that in regular product id order.
Code:
ORDER BY
CASE WHEN productid IN (45,37,18,101) then 0 else 1 end,
field(productid,45,37,18,101),
productid
To explain that the order by says check for productid in this specific list, if those numbers exist they are to be ordered at the top (assigned the 0), otherwise assign them in any order (assigned the 1),
next the field(productid,45,37,18,101) says, hey if the product ids are this, then I want them in exactly this order
and finally the productid says to order all other values by their productid
so if you have a list of
18
22
37
38
45
96
101
then they will be sorted by the above as follows:
45,37,18,101,22,38,96
NOTE that the order by FIELD is mysql specific. if you want to stick to the sql standard then do this:
Code:
ORDER BY
CASE WHEN
productid = 45 then 0
when productid =37 then 1
when productid=18 then 2
when productid=101 then 3
else 4 end,
productid
that will do the exact same as described above except without the proprietary code.