By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
458,249 Members | 1,647 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 458,249 IT Pros & Developers. It's quick & easy.

Updating stock levels from a CSV file or another table

P: 1
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
Share this Question
Share on Google+
3 Replies

Expert 2.5K+
P: 4,258
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

P: 1
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;
ERROR 1064: You have an error in your SQL syntax near ' acct_cpn set test_cpn.service=acct_cpn.acct where' at line 1
Aug 3 '06 #3

P: 37
yeah, you can take an advantage of update on multiple table with MySQL 4.0.4 and up
Aug 4 '06 #4

Post your reply

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