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 6646715
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T00:27:00+00:00 2026-05-26T00:27:00+00:00

I would like to build a safe dynamic select statement that can handle multiple

  • 0

I would like to build a safe dynamic select statement that can handle multiple WHERE clauses.

For example the base SQL would look like:

SELECT * FROM Books Where Type='Novel'

I would pass the function something like:

SafeDynamicSQL("author,=,Herman Melville","pages,>,1000");

Which would sanitize inputs and concatenate like:

SELECT * FROM Books Where Type='Novel' AND author=@author AND pages>@pages

The function would sanitize the column name by checking against an array of predefined column names. The operator would only be allowed to be >,<,=. The value would be added as a normal paramater.

Would this still be vulnerable to SQL injection?

There will be some string manipulation and small loops which will affect performance but my thoughts are that this will only take a few milliseconds compared to the request which on average take 200ms. Would this tax the server more than I am thinking if these requests are made about once a second?

I know this isn’t best practice by any means, but it will greatly speed up development. Please give me any other reasons why this could be a bad idea.

  • 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-26T00:27:01+00:00Added an answer on May 26, 2026 at 12:27 am

    It looks like you’re reinventing any number of existing ORM solutions which offer a similar API for creating WHERE clauses.

    The answer to your question hinges on what you mean by “The value would be added as a normal paramater.” If by that you mean performing string concatenation to produce the string you showed then yes, that would still be subject to SQL injection attack. If you mean using an actual parameterized query then you would be safe. In the later case, you would produce something like

     SELECT * FROM Books Where Type='Novel' AND author=? AND pages > ?
    

    and then bind that to a list of values like [‘Herman Melville’, 1000]. Exactly what it would look like depends on what programming language you’re using.

    Finally, if you pursue this path I would strongly recommend changing from comma-delimited arguments to three separate arguments, you’d save yourself a lot of programming time.

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

Sidebar

Related Questions

I would like to build a regexp in Java that would be passed in
I would like to build an application that will run on a web, this
I would like to implement a post build event that performs the following actions
I have a set of tables that I would like to build a view
i would like know how to build a rss feed that is evergoing using
Basically, I would like to build a list comprehension over the cartesian product of
Inspired by Eric Sink's interview on the stackoverflow podcast I would like to build
I would like to do remote deployment from my build machine onto a server.
I would like to ask you which automated build environment you consider better, based
I would like to be able to build test applications (e.g. the nightly Minefield/Firefox)

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.