update with joins

Questions about the MySQL, PostgreSQL, and most other databases, as well as using it with PHP can be asked here.

Moderator: General Moderators

Post Reply
User avatar
ol4pr0
Forum Regular
Posts: 926
Joined: Thu Jan 08, 2004 11:22 am
Location: ecuador

update with joins

Post by ol4pr0 »

I dont know if this is possible.

something like

UPDATE t.1,t2 SET this=that WHERE t1.unique_id = t2.unique_id ect..
visionmaster
Forum Contributor
Posts: 139
Joined: Wed Jul 14, 2004 4:06 am

Re: update with joins

Post by visionmaster »

Hello,

Yes, you can cross table delete as well as cross table update. Check out these links:
http://www.electrictoolbox.com/article/mysql
http://www.electrictoolbox.com/article/ ... le-update/

Example:

UPDATE product p
INNER JOIN productPrice pp
ON p.productId = pp.productId
SET pp.price = pp.price * 0.8
WHERE p.dateCreated < '2004-01-01'
Post Reply