search

Home  >  Q&A  >  body text

php - MySQL two tables query records with the same field and output a field


user table


single table

As shown in the figure, how to query the same records of user and user in the single table and output the id of the user table and the exam_name field of the user single table

Or how to change this table to make it better

still have a question

If you want to modify the user in the user table, how can the user corresponding to the single table be modified at the same time? I’m a newbie and I don’t understand very well. I hope my friends can help me and teach me. Thank you

phpcn_u1582phpcn_u15822735 days ago760

reply all(3)I'll reply

  • phpcn_u1582

    phpcn_u15822017-06-23 09:13:33

    select a.id,a.user,b.exam_namc from user as a join single as b on a.user = b.user

    reply
    0
  • 过去多啦不再A梦

    过去多啦不再A梦2017-06-23 09:13:33

    No debugging
    1,

    select u.id, u.user, s.exam_name from user u, single s where u.user = s.user

    2,

    update user u,single s  set u.user = '值', s.user = '值' where u.user = u.user and u.id = '条件'

    reply
    0
  • 某草草

    某草草2017-06-23 09:13:33

    To join two tables when selecting, you can check the usage of sql join.

    reply
    0
  • Cancelreply