PHP Query

I need to write a Query that grabs a number from a specific table but I'm not sure how to write it.

The table entry that I need to look at has the following;
entry_id, title, url_title
there are entries in this table ;
entry_id = 353
title = 230
url_title = order_230

entry_id = 354
title = 231
url_title = order_231

entry_id = 355
title = 232
url_title = order_232

I need to write a query that grabs the title value and add 1 to it title +1 where the url_title has the highest value.  
So from the data above I would need to write something like;
$Q = SELECT title
FROM My-Table
WHERE url_title Contains order_% That is the highest value.

Open in new window

The query needs to contain the order_ part cause not every entry in that field is formatted the same way.  There are other title formats.
Does this make sense?
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Chris StanyonWebDevCommented:
Does the number in the title column ALWAYS match the number from the url_title column?
rgranlundAuthor Commented:
Chris StanyonWebDevCommented:
Not entirely sure what you're trying to do, but have a look at this and see if does what you need:

// Select the record with the highest title where url_title starts with order_
SELECT title FROM yourTable WHERE LEFT(url_title, 6) = "order_" ORDER BY title DESC LIMIT 1;

// Update the record with highest title by adding 1 to the current value
UPDATE yourTable SET title = title +1 WHERE LEFT(url_title, 6) = "order_" ORDER BY title DESC LIMIT 1;

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
rgranlundAuthor Commented:
I think this is what I need.  For clarification, what does the "6" represent? (LEFT(url_title, 6))
Chris StanyonWebDevCommented:
LEFT(url_title, 6) means the 6 leftmost characters of the url_title field (which would match order_)
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today

From novice to tech pro — start learning today.