Skip to main content

select clients.email

table "clients"
+------+-------------+-----------+
   id  |  email      |  otherinfo|
+------+-------------+-----------+
   1   |test@ts.ts   |   .....   |
+------+-------------+-----------+
   2   |test2@.ts.ts |   ....    |
+------+-------------+-----------+

table "comptes"
+------+-------------+---------------+
   id  |  login      |   id_clients  |
+------+-------------+---------------+
 1     |     test    | 1             |
+------+-------------+---------------+
 1     |     test2   | 2             |
+------+-------------+---------------+
 etc.  |    etc.     |       etc..   |
+------+-------------+---------------+
   
'select clients.email,comptes.login   
from clients,comptes    
where clients.email='test2@.ts.ts'
 or comptes.login ='test';
   
select c.id, 'email' as matchtype
from clients c
where c.email = <email>
union all
select c.id, 'login' as matchtype
from comptes c
where c.login = <login>
   
select count(*) as numdups
from ((select c.id, 'email' as matchtype
       from clients c
       where c.email = <email>
      )
      union all
      (select c.id, 'login' as matchtype
       from comptes c
       where c.login = <login>
     )
    ) t
   
SELECT clients.email, comptes.login
  FROM clients
  JOIN comptes ON clients.id = comptest.id_clients
 WHERE clients.email='test2@.ts.ts'
    OR comptes.login ='test';
   
SELECT clients.email, comptes.login
FROM clients INNER JOIN comptes on clients.id = comptes.id_clients
WHERE clients.email='test2@.ts.ts' OR comptes.login = 'test';
   
SELECT cl.email, co.login
FROM clients AS cl
    INNER JOIN comptes AS co ON cl.id = co.id_clients
WHERE cl.email =  'test2@.ts.ts' OR co.login = 'test'