Link to home
Create AccountLog in
Avatar of gingera
gingera

asked on

MYSQL PHP: How to update a column with value in another table?

PHP MYSQL


Hello,

How do I insert value into a column based on value from another table?

For example, I want to insert the Category Name into all rows in TABLE 1, by checking their Category ID and obtaining the Category Name from TABLE 2.

TABLE 1
[ code ] [ category id ] [ category name ]
[ 001 ] [ 50 ] [  ]
[ 002 ] [ 60 ] [  ]
[ 003 ] [ 70 ] [  ]

TABLE 2
[ category id ] [ category name ]
[ 50 ] [ Toys ]
[ 60 ] [ Books ]
[ 70 ] [ CD ]





How do I write a mysql query or PHP script to do this?

Thanks.

ASKER CERTIFIED SOLUTION
Avatar of hernst42
hernst42
Flag of Germany image

Link to home
membership
Create a free account to see this answer
Signing up is free and takes 30 seconds. No credit card required.
See answer
SOLUTION
Avatar of Guy Hengel [angelIII / a3]
Guy Hengel [angelIII / a3]
Flag of Luxembourg image

Link to home
membership
Create a free account to see this answer
Signing up is free and takes 30 seconds. No credit card required.
Avatar of gingera
gingera

ASKER

THANKS!!!