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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T02:36:15+00:00 2026-05-27T02:36:15+00:00

In the wiki for node-mysql, I noticed that variables (kind of) were inserted into

  • 0

In the wiki for node-mysql, I noticed that variables (kind of) were inserted into the SQL query in 2 different ways, one is by inserting a variable in the middle of the query string, and the other way is by putting ? in the query string and defining the values for these ? in an array in the next argument. The values replacing ? in the query are escaped.

What is the difference and when should I use one over the other? (If we want the table name to be a variable, should it be escaped?)

Wiki Code

client.query(
    'INSERT INTO '+TEST_TABLE+' '+
    'SET title = ?, text = ?, created = ?',
    ['super cool', 'this is a nice text', '2010-08-16 10:00:23']
);

Wiki Link: https://github.com/felixge/node-mysql

Wiki extract:

Sends a sql query to the server. ‘?’ characters can be used as placeholders for an array of params that will be safely escaped before sending the final query.

This method returns a Query object which can be used to stream incoming row data.

  • 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-27T02:36:15+00:00Added an answer on May 27, 2026 at 2:36 am

    Always favor option 2, since they are SQL injection proof. Option 1 will get your site hacked within 5 minutes, while hackers are going to have a hard time breaking option 2.

    Even in performance option 2 may be a little bit faster.

    However: Table names cannot be escaped with the ? so don’t go there. Just make sure that users can’t enter the table name manually and you’ll be safe from hackers.

    -edit-

    Why would you want to make table names variable anyway?

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

Sidebar

Related Questions

Could anyone explain what node means in MySQL? This one is talking about nested
In wiki article for REST it is indicated that if you use http://example.com/resources DELETE,
Here is how I've done: https://github.com/joyent/node/wiki/Using-Eclipse-as-Node-Applications-Debugger but in the image after Now start making
I installed node.js with the instructions from node.js wiki. So I put the debian
I've got a build that was previously working fine on the Jenkins Master node
Following the instructions here: https://github.com/ry/node/wiki/Building-node.js-on-Cygwin-(Windows ) I've tried installing on two machines, either of
I had installed node by following article https://github.com/ry/node/wiki/Building-node.js-on-Cygwin-%28Windows%29 Now i had made a test.js
I want to get some node (for example, schools, kindergartens) from Planet.osm (http://wiki.openstreetmap.org/wiki/Planet.osm), the
Using a default index, one can do nodeIndex.get(message, Hello) for exact matches, or nodeIndex.query(message,
I've been looking into using Node.js + CoffeeScript for my project instead of the

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.