I can do this a round about way, loading a lot of arrays and comparing values, but there HAS to be an easier way to do this (which is what I\'m hoping for).
Basically I\'ve got a table with columns:
PKEY (primary key) , PRODUCT_PKEY (pkey of seperate table) and the columns PRODUCTID_X
Where X is the number of each PKEY in the Product table. Thus, the number of columns can change as things are added / removed.
Currently, the table is PKEY, PRODUCT_PKEY, PRODUCTID_10, PRODUCTID_11, PRODUCTID_12, PRODUCTID_13, PRODUCTID_14. But as I said before, adding or removing products will change the table by removing / adding corresponding PRODUCTID_X column.
So, what I\'m trying to do, is pick out a row where the PRODUCT_PKEY is equal to a known value, but then I need to pick out the Y PRODUCTID_X columns that have the greatest values
So for example, if it was filled with:
PKEY 12
PRODUCT_PKEY 10
PRODUCTID_10 2
PRODUCTID_11 6
PRODUCTID_12 1
PRODUCTID_13 2
PRODUCTID_14 5
And I wanted the top 2 scores, I would get back PRODUCTID_11: 6 and PRODUCTID_14: 5
Like I said at the top, I\'ve got this, but its pretty lengthy, and I\'m sure there just has to be a simpler solution. Anythoughts?