Latest Post

Error: No input file specified.

While trying to run a codeigniter app the other day I came across this error just after I had finished uploading the files and making the ne...

Wednesday, October 7, 2009

Example: mysql update with inner join

UPDATE product
INNER JOIN product_price
ON product.productId = product_price.productId
SET product_price.price = product_price.price * 1.5
WHERE product.dateCreated < '2009-10-23'


NOTE: This applies to MySQL version 4.0 or higher

14 comments:

  1. Woks like a charm...

    Thanks

    ReplyDelete
  2. Thanks, that was useful. The MySQL documentation is lacking a decent basic example like this.

    ReplyDelete
  3. You're welcome, i'm glad the sample helped you.

    ReplyDelete
  4. Hi , if I had zero at the left like 0015.. how it will keep zero instead 15?.
    Thank you

    ReplyDelete
  5. hi @anonymous, may you please give an example as i'm not quite sure i get your question.

    ReplyDelete
  6. I have been looking for this query forever, couldn't even find it in any books. Thank you.

    ReplyDelete
    Replies
    1. You're welcome, i also had been looking for a while for thiss so when i found it i decided to post it here.

      Delete
  7. I found this blog on time, it's saves lot of my time. Thank you very much for sharing with us.

    ReplyDelete
  8. you are really "Blessed"!
    I'm still learning mySQL.
    I just thought this was impossible... and then I found this page..

    Thanks!

    ReplyDelete
  9. glad you found this helpful :)

    ReplyDelete
  10. Perfect example.. Thank You.

    ReplyDelete

Chitika Ads