[PHP][MYSQL]Get highest value
Posted on 2009-05-04
In PHP I have a table with rows. The rows are currently within a SQL database and are stored by a value call position in which the will be loaded with ORDER BY ASC(position).
What I am having trouble doing is finding the row with the highest value of position WHERE parentseries='$parent' AND category='$category'
I need to do this when I am adding a new variable. In a sort it's an auto increment of my own. But I cannot use normal auto Increment as this table is shared with other product tables.
example of table:
parentseries | category | data | position
1721 14 ... 1
1721 14 ... 2
1532 14 ... 1
1532 14 ... 2
What now want to happen is if I add another category 14 item that it will find all other category 14 items that are parentseries 1721 and find which one has the highest position integer.