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

The Archive Base Latest Questions

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

I have the following database structure. ID | Name | Marks I am trying

  • 0

I have the following database structure.

ID | Name | Marks

I am trying to insert records in my PHP script. If the record doesn’t exist, I’m creating a new record. If it does exist, I’m concatenating the marks column with the new marks.

$strSQL = "Replace into student set ID = '".$id."', 
                 name = '".$name."', marks= CONCAT_WS(',',Marks,'".$marks."')";

The query is running fine but concat is not working. The old record is being overwritten by the new one. I tried CONCAT too.

Thanks

  • 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:21:08+00:00Added an answer on June 6, 2026 at 5:21 am

    The proper way to handle this is with a separate normalized table holding student ids and marks. Use INSERT IGNORE to insert the student info in to the student table, and then insert the marks into the marks table, multiple rows per student. This also allows you to store a date along with each mark added to the table, or other information (like what course it belongs to). Note that I wouldn’t usually recommend using INSERT IGNORE to create a row, but instead check first in code if the row exists and only insert if it doesn’t.

    CREATE TABLE marks (
       markID INT NOT NULL PRIMARY KEY AUTO_INCREMENT,
       studentID INT NOT NULL,
       mark VARCHAR() NOT NULL,
       markdate DATETIME NOT NULL
    );
    
    /* First execute the insert, which will ignore errors if it already exists */
    INSERT IGNORE INTO student (ID, name) VALUES ($id, '$name');
    
    /* Then insert the new marks. Loop to add as many new marks as needed */
    INSERT INTO marks (studentID, mark, markdate) VALUES ($id, '$marks', NOW());
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have the following database structure: Event table Id - Guid (PK) Name -
I have the following database structure: Sites table id | name | other_fields Backups
I have the following database structure (simplified) Store StoreId RateId Products ProductId Name Rates
I have the following database structure: Notice that the field fk_parent_group_id can either be
I have no control over database schema and have the following (simplified) table structure:
I have two database tables with the following structure: actions: action_id int(11) primary key
I have the following database design: Employee Table: EmployeeID, Name, OrgCode Department Table: OrgCode,
I have the following database design: Employees Table: EmployeeID, Name, OrgCode Departments Table: OrgCode,
I have the following database design: Employees Table: EmployeeID, Name, OrgCode Departments Table: OrgCode,
In PHP, I have following Singleton Database Class: class Database { private static $instance;

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.