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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T05:26:52+00:00 2026-06-06T05:26:52+00:00

I am using the MySQL driver for Node.js node-mysql but struggling with the syntax

  • 0

I am using the MySQL driver for Node.js “node-mysql” but struggling with the syntax to do a REPLACE into and increment a counter. Here’s what I have so far, note the count field is where I want to increment the current table value by 1:

connection.query('REPLACE INTO links SET ?', { symbol: statName, timestamp: now, count: count + 1  }, function(err, result) {

Can anyone advise on how to do this?

  • 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-06-06T05:26:54+00:00Added an answer on June 6, 2026 at 5:26 am

    I found the solution in using INSERT with ON DUPLICATE KEY UPDATE:

    connection.query('INSERT INTO links SET symbol = ?, timestamp = ?, title = ?, url = ? ON DUPLICATE KEY UPDATE count = count + 1', [statName, now, interaction.data.links.title[y], interaction.data.links.url[y]], function(err, results) {
                    if (err) console.log(err);
                });
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Using MySQL and I have data being loaded into a table every second. I
There is a similar question here but regarding the class path. ClassNotFoundException com.mysql.jdbc.Driver I've
I am using nodejs and the node-mysql driver. I find myself doing repetitive boiler
I am using node-mysql driver for a node.js app. Instead of having to set-up
I am building an app on node.js using express, and node-mysql driver. There is
I have been using CI just fine using the MySQL driver. I want to
I am using following prepared statement : Class.forName(com.mysql.jdbc.Driver); con=DriverManager.getConnection(jdbc:mysql://localhost:3306/mysql,root,root); String query=select ename from ?
(Using MySQL and PHP) I have a search form that will allow my users
Using MySQL, I have three tables: projects : ID name 1 birthday party 2
MySQL Query works fine using MySQL workbench but produces an error when I am

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.