Home > other >  SQL Insert with join?
SQL Insert with join?

Time:03-13

I have 2 tables [First Table][1] [Second Table][2] [1]: https://i.stack.imgur.com/gkAL4.png [2]: https://i.stack.imgur.com/2I4YN.png The question I need to know is how do I insert into Table 1 with a value for score when I only have the email to work with.

CodePudding user response:

I suppose the id are the same in both tables.

You can INSERT from a SELECT

INSERT INTO table1 SELECT id, 99 FROM table2 where email = "xxx";

With 99 the score to add and xxx the email

  •  Tags:  
  • sql
  • Related