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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T14:28:48+00:00 2026-05-23T14:28:48+00:00

I am using PHP scripts on my mySQL database. What I have is an

  • 0

I am using PHP scripts on my mySQL database. What I have is an inventory of products that is being pulled for a search page. I have this working fine, and my search page is working flawlessly. The only thing I cannot figure out is how to update the stock of each product in the database. I have a new file that needs to match up with the product number and then replace the data in one column of the mysql database. Much like this below

mysql database:

ProductNumber………………ProductStock

12345678………………………………1

New file:

12345678………………5

Basically I need the new file to match with the product number on the mysql and replace the product stock with the new number. All of this in PHP.

  • 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-05-23T14:28:48+00:00Added an answer on May 23, 2026 at 2:28 pm

    You don’t say how many rows you got in that database. Usually individual UPDATEs are pretty slow.

    You can

    • load your “new stocks” file into a temporary table using LOAD DATA INFILE
    • make an UPDATE using a JOIN to set the values in your products table

    This will be a few orders of magnitude faster.

    Update with the syntax to use on mysql :

    UPDATE products p JOIN temp_products t ON (p.id=t.id) SET p.stock = t.stock;
    

    Note that you need special privileges for LOAD DATA INFILE.
    You can also use LOAD DATA INFILE LOCAL (check the docs).

    Or, you can parse the file with PHP, generate an INSERT with multi-values in a temp table, and do a joined update. This will be a little slower than LOAD DATA INFILE, but much much faster than doing 27000 queries.

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

Sidebar

Related Questions

So I have a MySQL database that I'm using with a PHP site. Over
My project is a collection of PHP scripts using MySQL as a database and
I have two PHP scripts, both using the same session by calling session_name('MySessID') .
I have a simple php script on a server that's using fsockopen to connect
I have a PHP script that executes a .bat file using system(cmd /c C:\dir\file.bat);
I am using PHP and Mysql I have PHP script in which I rollback
I have php scripts that I have to run on linux as well as
So the scenario is this: I have a mySQL database on a local server
I have a MYSQL database which needs to be accessed by both PHP and
Using PHP, and MySql, I am trying to implement this rather snazzy in-place editor

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.