以下是我在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:
select accesses, email from user;
select email,count(*) as intentos from userstats where intento =1 group by email;
我该怎么做? 我需要一个查询来绘制。谢谢你提前..
答案 0 :(得分:1)
SELECT table1.email as Email,
table2.accesses as Acesses,
table1.attempts as Attempts
from table1
INNER JOIN table2
on table1.email = table2.email
答案 1 :(得分:0)
您可以使用INNER JOIN执行此操作
SELECT
t1.email, t1.accesses , t2.attempts
FROM table1 t1
INNER JOIN
table2 t2 ON
t2.email = t1.email;