March 25, 2012
query the two table for draw in one
Question by geronimo76
Here are my tables in 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 |
+----------+---------------------------+
query the two table for draw in one
Email Accesses Attempts
email1 24 70
email2 0 1
email3 0 1
email4 90 115
it is the sql:
- first ->
select accesses, email from user;
- second ->
select email,count(*) as intentos from userstats where intento =1 group by email;
how do I do this?
I need a query to do draw. thank’s in advance..
Answer by IT ppl
SELECT table1.email as Email,
table2.accesses as Acesses,
table1.attempts as Attempts
from table1
INNER JOIN table2
on table1.email = table2.email
Answer by Starx
You can use INNER JOIN to do this
SELECT
t1.email, t1.accesses , t2.attempts
FROM table1 t1
INNER JOIN
table2 t2 ON
t2.email = t1.email;