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

  • Home
  • SEARCH
  • 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 7996127
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T14:37:38+00:00 2026-06-04T14:37:38+00:00

Currently using a MySQL database Wanting to insert a new row into a table

  • 0

Currently using a MySQL database

Wanting to insert a new row into a table (t_2) for every matching entry in my where condition of another table (t_1).

I also want to include a count value from a seperate table for each entry (count from table counter) and a string value ‘decrease’ for each entry. No idea how to put this through, this is what I have so far:

INSERT INTO t_2(count,id,val='decrease')
SELECT MAX(count) as count FROM counter
SELECT id FROM t_1 WHERE val < 0

the error I am getting is:

1064 – You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ‘=’decrease’) SELECT count FROM counter SELECT id FROM t_1 WHERE val < 0′ at line 1

I know I probably shouldn’t have the val='decrease' but just wanted to illustrate I want that to be a string value inserted for each new row.

  • 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-04T14:37:41+00:00Added an answer on June 4, 2026 at 2:37 pm

    Try this:

    INSERT INTO t_2 (count,id,val) 
    SELECT 
        (SELECT MAX(count) FROM counter),
        t_1.id, 
        'decrease'
    FROM t_1 
    WHERE val < 0,
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am wanting to insert a datetime into a MySql data base using Java
I'm new to database design and am currently using MySQL Workbench to help me
I am currently using PHPmyadmin to store data in my mySQL database. The android
I'm currently developing a website which stores bookmarks in a MySQL database using PHP
we are currently working on a new web application using Java and MySql. We
I have a MySQL database holding hierarchical data using the Closure Table method. A
I'm currently developing a web application using MYSQL database InnoDB format and need some
I am currently using mysql database at server and for local sqlite in my
currently I'm using phpunit to write tests for some functions that access a mysql-database.
I have a MySQL database (currently using phpmyadmin to manage) that I would like

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.