0

I have a database named creative_db Table name is store_weblinks. Now inside this table there are several columns that holds the entire site's weblinks. My focus is on this column - weblinks_status

Now weblinks_status contains 2 values = waiting and live

So here's what I intend to do - Update any 10 waiting to live status.

I think I need a loop of some kind that would keep a count of how many successful edits are taking place. Once that hits 10 it will stop processing..

So, its like this -- Check if the current item of weblinks_status is waiting. If it is waiting then change it to live and increment the loop counter else proceed to the next waiting item..

Need your help!

1
  • You don't need a loop. You just need a LIMIT Commented Oct 3, 2014 at 12:04

1 Answer 1

2

Try this STATEMENT:

UPDATE store_weblinks 
SET weblinks_status="live" 
WHERE weblinks_status="waiting" 
LIMIT 10;

This should work to update any 10 entries from waiting to live.

Sign up to request clarification or add additional context in comments.

2 Comments

I ran this query but nothing is happening :( no error codes no change in the database.
Did you run the query directly in your sql database or with PHP? If you ran it with PHP you could try outputing sql errors with this function mysql-error . If you have any entries that would get updated but do not then you should get a sql error that will help.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.