search

Home  >  Q&A  >  body text

php - mysql table field problem

I have a question. I have a table A and a table B. Table A is the main table, used to store the main information, and table B is an additional table, used to store secondary information. How can I bring one of the fields of table B into Copy the value in the above field to the main table?

过去多啦不再A梦过去多啦不再A梦2871 days ago455

reply all(3)I'll reply

  • 迷茫

    迷茫2017-05-16 13:02:36

    UPDATE A INNER JOIN B ON A.id = B.id SET A.a = B.b;

    A.id = B.id: the associated fields of the two tables;
    A.a: the field that receives the data from table B;
    B.b: the field that will be copied to table A.

    reply
    0
  • 过去多啦不再A梦

    过去多啦不再A梦2017-05-16 13:02:36

    First you need to add this field to table A, and then update the joint table
    Or you can create a view for them if you need a simple query

    reply
    0
  • 过去多啦不再A梦

    过去多啦不再A梦2017-05-16 13:02:36

    A relates to B, join table query

    reply
    0
  • Cancelreply