Derokorian
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:
gallery_groups
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.
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 |
.....
gallery_groups
+--------------------------------------+
|id_gal| gal_name | gal_short |
+------+-------------------+-----------+
| 1 | 2011 Golf Outting | golf_2011 |
| 2 | 2011 Celebrity ...| dtco_2011 |
...
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
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
though the question is closed, you can read up this article for update with join:
https://www.experts-exchange.com/A_1517.html
https://www.experts-exchange.com/A_1517.html
ASKER