0

I have two tables structure like below

Table1

Serial  |   Src            | Albumid(primarykey)  
________|__________________|________
   1    |   /root/wewe.jpg |   20
   2    |   /root/wewe.jpg |   21
   3    |   /root/wewe.jpg |   21
   4    |   /root/wewe.jpg |   23
   5    |   /root/wewe.jpg |   18

Table2

Albumid |  Albumname       | AlbumCover  //albumid is secondary key ref. to first table
________|__________________|________
   20   |   AAA            |   null
   21   |   bbb            |   null
   31   |   vcc            |   null
   42   |   ddd            |   null
   18   |   eee            |   null

I followed this POST two update my Albumcover in Table2 using Serial no. of first table..

create proc AddCover @Serial int
as
Begin
update Table1 set albumcover='somthing' where table1.serial = @Serial
end

Can i do like this using foregin key constraint??

Andy Refuerzo
  • 3,312
  • 1
  • 31
  • 38
user3860465
  • 55
  • 2
  • 9

1 Answers1

0

You'll need to do the update on Table2. To tell it to have a condition based on values from table1, check this post for examples:

MySQL - UPDATE query based on SELECT Query

Community
  • 1
  • 1
Rachael
  • 424
  • 2
  • 7