Re: multiple tables - mysql 3.x and 4.x compatibility
reza,
The following statements should work:
===========================
select p.product_model, t.price
into outfile 'prices_temp.txt'
from products as p, products_temp as t
where p.product_model = t.product_no;
load data infile 'prices_temp.txt'
replace into table products (product_model, product_price);
===========================
You could save this in a file - say 'update_prices.sql' and then execute it as follows:
mysql> source path/to/update_prices.sql
However, you will need to delete 'prices_temp.txt' after the statements are executed - otherwise you'll get a 'file already exists' error next time the 'select ... into outfile ...' executes. You will also need FILE privileges to execute the statements. You could get round this by generating a different filename each time - maybe using the date & time as part of the name.
There may be a neater way of doing this with MySQL statements, but the easiest approach will probably be to do the updates with the scripting language, e.g. PHP or Perl, that is used for the interface between the website and MySQL.
Nick Roper
Subject
Views
Written By
Posted
6094
July 08, 2004 02:32PM
2737
July 11, 2004 04:29PM
2763
July 17, 2004 11:38AM
Re: multiple tables - mysql 3.x and 4.x compatibility
2966
July 18, 2004 09:20AM
3047
August 03, 2004 06:11PM
2366
August 04, 2004 01:12AM
Sorry, you can't reply to this topic. It has been closed.
Content reproduced on this site is the property of the respective copyright holders.
It is not reviewed in advance by Oracle and does not necessarily represent the opinion
of Oracle or any other party.