php - 比较两个表并将结果存储在第三个表中 [英] php - Compare two tables and store result in third table
本文介绍了php - 比较两个表并将结果存储在第三个表中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我在数据库中有两个表。
I have two tables in my database.
我想比较电子邮件
code> table-1 与 email2
的每一行 table-2
如果它们的内容匹配,那么我想存储 table-1
到 Mac的
mac
I want to compare the each row of email
of table-1
with the each row of email2
of table-2
if their content matches then I want to store the mac
of table-1
to Mac
of Result table
.
Email Mac
value1 21321
value2 45666
这是表格2
this is table-2
Name email2
name1 xyyxas
name2 xxxxxx
这是结果表
this is Result Table
ID Mac
1 21321
2 45666
$ b b
我完全没有逻辑这里我尝试加入查询,但他们似乎不适合我的情况。
I am completely out of logic here I tried join queries but they doesn't seem to be fit in my case.
我很清楚
推荐答案
您可以使用带有内连接的插入选择
you can use a insert select with inner join
insert into result_table (mac)
select table1.mac from table1
inner join table2 on table1.email = table2.email
这篇关于php - 比较两个表并将结果存储在第三个表中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文