Link to home
Start Free TrialLog in
Avatar of drakeshe
drakesheFlag for Australia

asked on

[PHP][MYSQL]Get highest value

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.

Thank you.
ASKER CERTIFIED SOLUTION
Avatar of jausions
jausions
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of drakeshe

ASKER

Thank you! This worked perfectly! Exactly what I needed
Thank you! It worked perfectly! Exactly what I needed