Monthly Archive: 十一月 2013

查询或者修改数据的inner连接方法

查询或者修改数据的inner连接方法

http://home.51cto.com/index.php?s=/Home

1

UPDATE product p, productPrice pp

SET pp.price = pp.price * 0.8

WHERE p.productId = pp.productId

AND p.dateCreated < ‘2004-01-01’

2

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’

3

UPDATE product p

LEFT JOIN productPrice pp

ON p.productId = pp.productId

SET p.deleted = 1

WHERE pp.productId IS null