I need some help here i have this 2 tables :
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.. |
+------+-------------+---------------+
In my website when a user crate an account he give the information of both tables. So i want to test if LOGIN or EMAIL exist in the database before adding them, something like this
'select clients.email,comptes.login
from clients,comptes
where clients.email='test2@.ts.ts'
or comptes.login ='test';
But this query return empty result, i tired other combination but none give the right results .So what i am messing here
You don’t need a join at all to see if they exist. The following query returns the id of any matching record:
This gives you the matching ids and tells you where the duplicates are appearing (if that is of interest). If you just want a 0 or 1 flag to specify the existence of duplicates, do this: