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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T20:16:35+00:00 2026-06-01T20:16:35+00:00

I need to be able to add a set of values into a table

  • 0

I need to be able to add a set of values into a table every time a new user is added into my system.

When the user is added, I want to look into my ‘Tags’ table, and insert a new entry into the ‘Tag_Score’ table for each of the IDs in the ‘Tags’ table.

I tried the following based on something i found online but although the logic seems sound, it doesn’t seem to be working

DECLARE @LoopVar INTEGER
SET @LoopVar = ( SELECT MIN(Tag_Score.T_ID) 
FROM Tags ) WHILE @LoopVar IS NOT NULL 
BEGIN 
INSERT INTO  `a3360218_DD`.`Tag_Score` (
`A_ID` ,
`T_ID` ,
`Score` ,
`Visits`
)
VALUES (
'" . $accountID . "', @LoopVar ,  '0',  '0'
)
SET @LoopVar = ( SELECT MIN(Tag_Score.T_ID) 
FROM TheTable
WHERE @LoopVar < T_ID ) 
END

The error given 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 'WHILE @LoopVar IS NOT NULL 
BEGIN 
INSERT INTO  `a3360218_DD`.`Tag_Score` (

' at line 2 

Thanks in advance

Matt

  • 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-01T20:16:36+00:00Added an answer on June 1, 2026 at 8:16 pm

    You haven’t posted any table layouts, so I’m shooting in the dark here, but this kind of query should work for you:

    INSERT INTO Tag_Score (A_ID, T_ID, Score, Visits)
    SELECT A_ID, T_ID, 0,  0
    FROM Tags
    WHERE A_ID = $accountID;
    

    Note the removal of all those unnecessary back-ticks (ie `) that are only necessary when you have a schema name that is a reserved word, and look how readable it is now!

    Keep things simple – avoid complex SQL if you can.

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

Sidebar

Related Questions

I need to be able to add rows to a table dynamically with jQuery
I want to be able to look values up by a key in same
When I add new values to a listview using : Set lstView = ListView(0).ListItems.Add(,
Users need to be able to add a specific type of column to an
Need to be able to pull Magento products into an external template. Need to
I have a form which I want the user to be able to export
Basically i'm trying to set something where a user enters some text into a
Users of the website need to able to store images in their area ,
I need to be able to disable the selection of future dates within the
I need to be able to scroll a RichTextBox to the bottom, even when

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.