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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T01:46:57+00:00 2026-06-14T01:46:57+00:00

I have a mysql table with following columns: filterid productid value groupid I want

  • 0

I have a mysql table with following columns:

filterid    productid   value   groupid

I want to export the rows of this table (Only selected rows) to a CSV file.
I know how to do the exporting part.

For example, if I have exported the rows based on product ID, let say exported rows are:

4   13307   USA|Quebec|Rest of Canada   750
9   15963   USA|Quebec|Rest of Canada   1
9   13618   USA|Quebec|Rest of Canada   1
9   16210   USA|Quebec|Rest of Canada   1
9   16666   USA|Quebec|Rest of Canada   1

Out of total 100 rows.

Now, I have exported this content into a CSV file and want to import it back to my mysql table where it should update only rows matching with the product id’s which are in my exported CSV file without disturbing rest of the table content.

Is it possible to do that?

After googling, what I found is that I can import a CSV to a table using this code

LOAD DATA LOCAL INFILE 'filename.csv' INTO TABLE my_table FIELDS
TERMINATED BY ',' 
ENCLOSED BY '' 
LINES TERMINATED BY '\n'

Please suggest a way to achieve this.

I can provide you with more sample code if you need.

Thank You!

  • 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-14T01:46:59+00:00Added an answer on June 14, 2026 at 1:46 am

    I think he was asking the question because he didn’t know how to use INFILE with a WHERE clause:

    Now, I have exported this content into a CSV file and want to import
    it back to my mysql table where it should update only rows matching
    with the product id’s
    which are in my exported CSV file without
    disturbing rest of the table content.

    If you want to use a script to do what you mentioned, you can try the following:

    // set up your database connection
    $fp = fopen('your_csv_file.csv','r') or die("**! can't open file\n\n");
    
    // loop through your lines
    while($csv_line = fgetcsv($fp,1024)) {
    
        $filterid = $csv_line[0];
        $productid = $csv_line[1];
        $value = $csv_line[2];
        $groupid = $csv_line[3];
    
        $update =  "UPDATE your_table(filterid, productid, value, groupid) ";
        $update .= "VALUES('$filterid', '$productid'; '$value'; '$goupid') WHERE productid='$productid'";
    
        // run $update on your database
    }
    
    fclose($fp) or die("**! can't close file\n\n");
    

    It should at least point you in the right direction..

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

Sidebar

Related Questions

I have three mysql table from same database Db1. Three tables have following columns.
I have created a mysql table with the following columns... item_price, discount, delivery_charge, grand_total
I have a MySQL table with the following columns: id(int), date (timestamp), starttime(varchar), endtime(varchar),
I have a (mysql) database table with the following columns: NAME | String (Unique)
I have one MySQL table, users , with the following columns: user_id (PK) email
I have a mySQL table that includes the following three columns: IDENT, TIME, and
I have a mysql table with the following columns SNP Probe Genotype_00 Mean_00 Std_00
Hello I have following columns in mysql table: rating1, rating2, price, cond, approved Is
I have a mysql table with the following columns: id (autoincremented primary key) user_id
I have a database table containing the following columns: id code value datetime timestamp

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.