SQL - Updating a table with values from another table

Questions about the MySQL, PostgreSQL, and most other databases, as well as using it with PHP can be asked here.

Moderator: General Moderators

Post Reply
keveh
Forum Commoner
Posts: 27
Joined: Mon Aug 08, 2005 5:50 am

SQL - Updating a table with values from another table

Post by keveh »

This is a simple error, and I have looked all over these forums and google to try and get it to work, but if refuses to.

Basically i have two tables which are exactly the same, apart from the field names:

pictures
- id
- prod_id
- picture
- default

pictures_prd
- picture_id
- prod_id
- picture_name
- default_img

What i want to do is update the table pictures_prd.default_img to the same value as pictures.default where pictures_prd.prod_id is equal pictures.prod_id

I have tried multiple queries that I have seen on here and on the mysql site.

I was wondering if somebody could give me some SQL that they think will work?

Thanks in advance.
User avatar
Burrito
Spockulator
Posts: 4715
Joined: Wed Feb 04, 2004 8:15 pm
Location: Eden, Utah

Post by Burrito »

what version of MySQL are you running?

knowing that will help us help you...(whether you can run sub queries or not).
keveh
Forum Commoner
Posts: 27
Joined: Mon Aug 08, 2005 5:50 am

Post by keveh »

This is info I've got from MySQL Administrator:

MySQL 4.1.20 via TCP/IP
Post Reply