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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T23:18:03+00:00 2026-06-17T23:18:03+00:00

I am trying to insert these values into a database, however, the INSERT and

  • 0

I am trying to insert these values into a database, however, the INSERT and WHILE clause are incompatible with each other. Does anybody have any ideas how I could achieve my desired results in a different manner.

public boolean updateAns()
{
    boolean success=true;
    DBController db=new DBController();
    db.setUp("IT Innovation Project");
    String sql="INSERT INTO kioskSurveyAns(survey_qn1,survey_qn2,survey_qn3) VALUES('"+radioText+"','"+radioText1+"','"+radioText2+"')SELECT survey_qn1,survey_qn2,survey3 FROM kioskSurveyAns WHERE survey_nric='"+nric+"'";

    if (db.updateRequest(sql) == 1)
    success = true;
    db.terminate();
    return success;
}
  • 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-17T23:18:04+00:00Added an answer on June 17, 2026 at 11:18 pm

    If you are using INSERT INTO...SELECT statement, there should be no VALUES keyword on it because the value that will be inserted came from the SELECT statement. eg

    INSERT INTO tableName (col1, col2)
    SELECT col1, col2
    FROM tableX
    WHERE....
    

    but looking back on your query, you want to UPDATE the rows based on the values of the controls. right?

    UPDATE kioskSurveyAns
    SET    survey_qn1 = 'rad1',
           survey_qn2 = 'rad2',
           survey_qn3 = 'rad3'
    WHERE  survey_nric= = 'richere'
    

    As a sidenote, the statement is vulnerable with SQL Injection. Please do parameterized your query using PreparedStatements

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

Sidebar

Related Questions

During onCreate() I'm trying to insert about 20 rows into the SQLite database (these
I am trying to insert a row into database. All entries insert correctly, however
I was trying to use executemany to insert values into a database, but it
Trying to insert 315K Gif files into an Oracle 10g database. Everytime I get
im trying to insert this query with mysql_query INSERT INTO um_group_rights (`um_group_id`,`cms_usecase_id`,`um_right_id`) VALUES (2,1,1)
I am trying to insert data into a SQLite database that is used for
I have this XML document I am trying to read in and insert into
I am trying to do a batch insert into a database, to try and
I am facing a really weird error,while trying to insert into a table called
I am trying to insert rows into a database when the database is first

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.