Link to home
Start Free TrialLog in
Avatar of Derokorian
DerokorianFlag for United States of America

asked on

Updating column value to the ID associated with it in another table.

Ok working on someone else's code I've run into the following problem with their photo gallery. There is a table to store the image, image path, gallery, etc... and a table to store the gallery name, a short name (for the url) and an id for the gallery. However the image table is story the short name for the gallery instead of the id. Example data:

gallery_images:
+------------------------------------------------------------------------------+
|id_image|img_filename|img_ext|img_path|  img_gal  | img_date |img_photographer|
+--------+------------+-------+--------+-----------+----------+----------------+
|   1    | dsc_004    | jpg   | ...    | golf_2011 |2011-06-10| My Name        |
|   2    | dsc_027    | jpg   | ...    | golf_2011 |2011-06-10| My Name        |
|   3    | dsc_523    | jpg   | ...    | dtco_2011 |2011-09-20| Someone's Name |
|   4    | dsc_544    | jpg   | ...    | dtco_2011 |2011-09-20| My Name        |
.....

Open in new window


gallery_groups
+--------------------------------------+
|id_gal|  gal_name         | gal_short |
+------+-------------------+-----------+
|   1  | 2011 Golf Outting | golf_2011 |
|   2  | 2011 Celebrity ...| dtco_2011 |
...

Open in new window


What I'm trying to do is create a query, that will update the gallery_images table, img_gal column to instead have the id of the gallery as listen in the gallery_groups table.
ASKER CERTIFIED SOLUTION
Avatar of Derokorian
Derokorian
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Derokorian

ASKER

I was able to find the answer on my own. Sorry to waste the experts' time!
Avatar of Guy Hengel [angelIII / a3]
though the question is closed, you can read up this article for update with join:
https://www.experts-exchange.com/A_1517.html