473,322 Members | 1,501 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,322 software developers and data experts.

Updating stock levels from a CSV file or another table

Hi there

I have a table in MySQL database on my web server that contains stock levels amongst other things. twice a day I get emailed an updated stock list in CSV format.

What I need is to update the stock quantities in my table with the values from the CSV file.

I have managed to successfully upload the CSV file into a different table I generated but I have no idea how to get the stock amounts updated.

The CSV file and the table have a product ID field which contains the unique reference to the product. In the CSV file there are products I do not list and in my table there are products that are not in the CSV file. These need to be ignored.

I need to somehow be able to tell it to look for the product ID and where it matches fill with the updated stock quantities.

Can anyone help me with this?

Thanks a lot.
Jul 27 '06 #1
3 3566
ronverdonk
4,258 Expert 4TB
Maybe I don't understand your problem correctly, but is this what you are looking for?

Expand|Select|Wrap|Line Numbers
  1. UPDATE Product, Csv SET Product.stock = Csv.stock 
  2. WHERE Product.Id = Csv.Id
Ronald :cool:
Aug 2 '06 #2
I am using MYSQL 3.23 and I get this message when trying a multi table update.
Does this only work on 4.0 or higher? Or do the fields have to be defined the same?

mysql> update test_cpn, acct_cpn set test_cpn.service=acct_cpn.acct where acct_cpn.cpn=test_cpn.coupon;
ERROR 1064: You have an error in your SQL syntax near ' acct_cpn set test_cpn.service=acct_cpn.acct where acct_cpn.cpn=test_cpn.coupon' at line 1
Aug 3 '06 #3
masdi2t
37
yeah, you can take an advantage of update on multiple table with MySQL 4.0.4 and up
Aug 4 '06 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

11
by: Jason | last post by:
Let's say I have an html form with 20 or 30 fields in it. The form submits the fields via POST to a php page which updates a table in a database with the $_POST vars. Which makes more sense? ...
1
by: Michael Thomas | last post by:
Hi everyone I have a database which I use to keep track of stock for the company that I work for. We are a retail chain with 8 locations at present and a head office. I need to keep track of...
9
by: simon.harris | last post by:
I have a 'master' stock list with current stock levels (integer) and another table that contains transactions (i.e. item#, #items added/ removed, date, user etc). What I need is an update query...
4
by: peter | last post by:
In the sample northwind database when an order is sent the sent value come of the instock value. I can not work out how they have done this . I can see that it is an eventprocedure but can not...
3
by: Grant | last post by:
I need some sample code showing how to manipulate data in my access database using C#. This is what Im trying to do: Dropdownlist with datagrid both bound to datasource. When the drop down list...
1
by: pashi | last post by:
Hi, I am having two tables Stock and OrderIssue as follow Stock ItemID, ItemName , Qty , ...
1
by: baker951 | last post by:
I have a problem that some companies in my supplier table deliver on more than one day in a week, is it possible to add more than one value to a single field or do i need seperate fields. Also i...
1
by: wboyd36 | last post by:
Can someone show me an easy code snippet to help update a table based on DDE data. Here is the "jist" of what I am trying to do.. 1. Get stocks/options symbols from portfolio management systems...
1
by: iceomnia | last post by:
$insertTable = "Table"; $query = "SELECT `gb`.`id` AS `id`, `gb`.`engineId` AS `engineId`, `gb`.`engineUPN` AS `engineUPN`, `gb`.`linkURL` AS `link`, `gb`.`imageURL` AS `image`,...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.