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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T09:04:06+00:00 2026-06-09T09:04:06+00:00

How do we deal with field with comma when using load data infile? i

  • 0

How do we deal with field with comma when using load data infile? i have this query:

$sql = "LOAD DATA LOCAL INFILE '{$file}' INTO TABLE sales_per_pgs 
        FIELDS TERMINATED BY ','
        LINES TERMINATED BY '\n'
        IGNORE 1 LINES
        (@user_id, @account_code, @pg_code, @sales_value)
        SET
        user_id = @user_id, 
        account_code = @account_code,
        product_group_code = @pg_code,
        sales_value = REPLACE(@sales_value, ',', ''),
        company_id = {$company_id},
        year = {$year},
        month = {$month}";

and a line from the csv looks like this:

139, pg89898, op89890, 1,000,000.00

where 1,000,000.00 is a sales value.

Currently, what is inserted in my database is only "1.

EDIT

The user downloads a form with columns like:

user id, account id, pg id, sales value

where the first three columns user id, account id, pg id, were populated and the sales value column is blank because the user has to fill it up manually… the user uses MS excel to do that…

after the form is completed, he will now upload it, in which i am using the load data infile command…

  • 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-09T09:04:08+00:00Added an answer on June 9, 2026 at 9:04 am

    Your content should really look like:

    "139", "pg89898", "op89890", "1,000,000.00"
    

    Then you could add the following to the command:

    ENCLOSED BY '"' ESCAPED BY "\\"
    

    And you won’t have an issue.

    Also, somethign you could try if you don’t have any paragraphs or strings with , in them:

    FIELDS TERMINATED BY ', '
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Scenario: I load some data into a local MySQL database each day, about 2
I have this large XML file. There is a field that I want to
I have a products table and each product have a category field (this is
I have to deal with a table where there is a set of fields
How do I get the LOAD DATA INFILE command to skip certain fields. Lets
I have a UIAlertView with a text field in it. This view works correctly;
I have a deal model that contains two date field. First one is start_date
I have a deals table, with a field start date in the controller i
I have a string that gets saved as rich text to a SQL field,
I am using mechanize to deal with a form . I have parsed the

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.