Etienne,
Wednesday, October 30, 2002, 1:51:32 PM, you wrote:
ED> I would like to know if MySQL allows some way to do
ED> "UPDATE SomeTable SET SomeColumn=(SELECT SomeExpression FROM SomeTable,
ED> SomeOtherTable WHERE SomeTable.ForeignKey=SomeOtherTable.PrimaryKey);"
ED> Although I had some ideas (like sending SELECT result to a file, deleting
ED> table SomeTable and reloading it from the file --- which would work except
ED> the fact that the file must not exist, as said by the doc), I could not find
ED> anything else than using some php script to do the job, row by row. If
ED> someone has an idea (waiting for MySQL 4.1 !?), it will be welcomed.
You can do it since 4.0.2, like:
UPDATE SomeTable, SomeOtherTable
SET SomeTable.SomeColumn=SomeOtherTable.SomeExpression
WHERE SomeTable.ForeignKey=SomeOtherTable.PrimaryKey;
You can also do it using PHP as well or the other way described for
DELETE here:
http://www.mysql.com/doc/en/ANSI_diff_Sub-selects.html
--
For technical support contracts, goto https://order.mysql.com/?ref=ensita
This email is sponsored by Ensita.net http://www.ensita.net/
__ ___ ___ ____ __
/ |/ /_ __/ __/ __ \/ / Victoria Reznichenko
/ /|_/ / // /\ \/ /_/ / /__ [EMAIL PROTECTED]
/_/ /_/\_, /___/\___\_\___/ MySQL AB / Ensita.net
<___/ www.mysql.com
---------------------------------------------------------------------
Before posting, please check:
http://www.mysql.com/manual.php (the manual)
http://lists.mysql.com/ (the list archive)
To request this thread, e-mail <[EMAIL PROTECTED]>
To unsubscribe, e-mail <[EMAIL PROTECTED]>
Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php