Recently I needed to update a bunch of rows in mysql with information from another table. I will explain how to do this simple process.
- Open up phpmyadmin or similar database editor
- view the sql query below
UPDATE updatefrom p, updateto pp
SET pp.last_name = p.last_name
WHERE pp.visid = p.id
Lets say we have 2 tables one named main and one named updateto and one named updatefrom, In the first line we assign variables to these t tables (p and pp) from there we can call column names using this format table.columname. If we had first_name and last_name in both tables and wanted to update the “updateto” table with the info from “updatefrom” this is how you would write it.
Thanks! 🙂
That was exactly what I was looking for!
Regards,
Evert
thanx so much, Help me much 🙂
thank you! thank you! thank you!
Saved me from countless hours of more frustration 🙂
It’s so easy when you see it too!
I can’t believe it was that easy. You are the person. Your code explained things well. Thanks.
Thanks man, really helpful
Found this after a long search.
This should not be so difficult to find – in 1984 dBase II had this as a simple syntax. And so did all the subsequent DB programs.
Thank you for your extremely helpful and elegant solution.
This is one MYSQL command that is entirely intuitive.
Please keep up the great work – very much appreciated by us older chaps – I started in 1964 at Monash University in Melbourne Australia, start of a lifelong fascination with numbers.
Thank you.
It couldn’t be simpler.
This is so slick and simple. Thank you so much. Saved me hours!
This will also do…
UPDATE updateto pp INNER JOIN updatefrom p
on pp.visid = p.id SET pp.last_name = p.last_name
WHERE pp.status = ‘active’…
it is great thx
Актуальные купоны на скидку iHerb совершенно бесплатно! … Вы находитесь на странице iHerb, который на данный момент не работает iherb промокод на первый заказ в приложении
prednisone acetate ophthalmic pharmacy online prednisone how long does prednisone last in your system
In Etsy, Amazon, eBay, Shopify https://pint77.com Pinterest+SEO +II = high sales results
Топ 10 лучших онлайн-казино, которые заняли первые места в рейтинге игр на наличные деньги, доверия и других значимых критериев 2024 лучшие казино
Арктика – северная полярная область Земли, включающая окраины материков Евразии и Северной Америки, почти весь Северный Ледовитый океан с островами и прилегающие к нему части Атлантического и Тихого океанов. Название её происходит от греческого слова arctos (медведь) и связано со звёздами: Полярная звезда, находящаяся почти точно в зените над Северным полюсом, принадлежит к созвездию Малая Медведица.