Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 1026235
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T12:03:05+00:00 2026-05-16T12:03:05+00:00

IdList = 1,2,3,4,5,6,7,8,9,10 better: Foreach(id in IdList) Update MyTable set isDeleted = 1 where

  • 0

IdList = 1,2,3,4,5,6,7,8,9,10

better:

Foreach(id in IdList)
    Update MyTable set isDeleted = 1 where id = ?id

or

Update MyTable set isDeleted = 1 where id IN (?IdList)

Forgive my pseudocode, but I think it should be clear.
I know there are limits to the size of the list in an IN clause. It used to be 255 in Oracle.

I’m thinking multiple sqls will be slower, but maybe parsing the IdList will cause more overhead for the DB Server. Would it be better if the list was sorted?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-16T12:03:05+00:00Added an answer on May 16, 2026 at 12:03 pm

    The fewer queries to the database, the better. That said, this:

    Update MyTable set isDeleted = 1 where id IN (?IdList)
    

    …requires dynamic SQL because SQL doesn’t support a variable containing a comma separated list of values in an IN clause.

    If you’re constructing the query as a string before submitting it, concatenate the variable into that string before submission. Otherwise you’ll have to use MySQL’s dynamic SQL syntax, called PreparedStatements. See this link for Oracle dynamic SQL examples & info.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm wondering if there is a better way to do the following, IList<RoleViewModel> ReturnViewModel
I was just wondering about some CodeWarning (ConstructorsShouldNotCallBaseClassVirtualMethods), and if there is a better
can anyone think of a better way to do this? [AcceptVerbs(HttpVerbs.Post)] public ActionResult SaveAction()
Is there a better way (specially using Linq) to return a List/IEnumerable of the
Is there a better way to cast this list of guid strings to guids
Is there a better way to check if a LINQ projection query returns results:
So i think i maybe over-complicating things in my implementation, but here's what i'm
Is there a better way of doing this? I have a Linq-To-SQL query that
Which is better implementation or there is no difference? 1. public class Simple {
I know that IList is the interface and List is the concrete type but

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.