gpt4 book ai didi

mysql - 查询两张表合二为一

转载 作者:行者123 更新时间:2023-11-29 00:47:49 25 4
gpt4 key购买 nike

这是我在 mysql 中的表:

        ----------------1-------------------------  
+---------------------------+----------+
| email | attempts |
+---------------------------+----------+
| email1@gmail.com | 70 |
| email2@me.com | 1 |
| email3@hotmail.com | 1 |
| email4@gmail.com | 115 |
+---------------------------+----------+
---------------2------------------------
+----------+---------------------------+
| accesses | email |
+----------+---------------------------+
| 24 | email1@gmail.com |
| 0 | email2@me.com |
| 0 | email3@hotmail.com |
| 90 | email4@gmail.com |
+----------+---------------------------+

查询两张表合二为一

Email   Accesses    Attempts
email1 24 70
email2 0 1
email3 0 1
email4 90 115

是sql:

  1. 首先 -> 选择访问,来自用户的电子邮件;
  2. second -> select email,count(*) as intos from userstats where intento =1 group by email;

我该怎么做?我需要一个查询来绘制。提前致谢..

最佳答案

SELECT table1.email as Email, 
table2.accesses as Acesses,
table1.attempts as Attempts
from table1
INNER JOIN table2
on table1.email = table2.email

关于mysql - 查询两张表合二为一,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9858520/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com