2

I want to create a batch delete and/or update screen for records similar to how the iphone lets you batch delete text messages In other words when you click edit, it shows a checkbox next to all the records and you can then click a button that deletes them or changes a value.

I have discovered following syntax to insert a bunch of rows:

insert into tbl (...) values (...) (...) (...) ...

There also seems to be a way to batch delete using:

delete from tbl where id IN (1,2,3)

Is there a way to do a batch update?

I think I could then just collect an array of the id numbers for the records and run either a delete or update query depending on what button is pushed.

1 Answer 1

3

You can use WHERE condition same like you did for DELETE query like this:

UPDATE tbl SET col1='...', col2='...' WHERE id IN (1,2,3)

See this SQLFiddle

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

1 Comment

Thanks! First time I have seen sqlfiddle.

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.